Maven clean not deleting files

415 Views Asked by At

I have two files in my directory like this:

  • a.b.so
  • a.so

I want to delete only a.b.so.

So here is my Maven clean plugin entry in my pom.xml file:

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
  <execution>
    <id>auto-clean</id>
    <phase>prepare-package</phase>
    <goals>
      <goal>clean</goal>
    </goals>
    <configuration>
    <excludeDefaultDirectories>true</excludeDefaultDirectories>
     <filesets>
        <fileset>
      <directory>${project.build.directory}/libs/x86</directory>
      <includes>
        <include>*.so</include>
      </includes>
      <excludes>
       <exclude>a.so</exclude>
      <excludes>
       <followSymlinks>false</followSymlinks>
    </fileset>
      </filesets>
      <verbose>true</verbose>
    </configuration>
  </execution>
</executions>

Just for some backgorund of this, file a.b.so gets downloaded as a dependency then it gets renamed into a.so just before i execute the above entry. I copy file using maven depedency plugin. I don't know whether this affects the not deletion of a.b.so

In turn it always delete a.so. Even I tried including **/*, but it deletes a.so every time.

It never deletes a.b.so.

1

There are 1 best solutions below

0
On

For this particular example, you can try to replace this part:

  <includes>
    <include>*.so</include>
  </includes>
  <excludes>
   <exclude>a.so</exclude>
  <excludes>

with

  <includes>
    <include>a.b.so</include>
  </includes>