followSymlinks doesn't work for maven-clean-plugin

1.3k views Asked by At

I am trying to use "maven-clean-plugin" to delete additional files situated in /my/path folder.

<plugin>
   <artifactId>maven-clean-plugin</artifactId>
   <executions>
       <execution>
           <id>clean-on-cleaning</id>
           <phase>clean</phase>
           <goals>
               <goal>clean</goal>
           </goals>
           <configuration>                      
               <filesets>
                   <fileset>
                       <directory>target/dart</directory>
                   </fileset>
                   <fileset>
                       <directory>src/main/dart/.pub</directory>
                   </fileset>
                   <fileset>
                       <directory>src/main/dart/build</directory>
                   </fileset>
                   <fileset>
                       <directory>${env.APPDATA}/Pub/Cache</directory>
                   </fileset>
                   <fileset>
                       <directory>src/main/dart/packages</directory>    
                       <followSymlinks>false</followSymlinks>
                   </fileset>
               </filesets>
           </configuration>
       </execution>
   </executions>

"src/main/dart/packages" contains links. And one of the links points to "src/main/dart/lib" folder. I have set:

<followSymlinks>false</followSymlinks> 

So it shouldn't delete files in lib directory. But unfortunately it does. Where the problem could be?

Environment configuration:

  • Maven: apache-maven-3.3.3
  • Java version: 1.7.0_55(also tried on 1.8.0_51)
  • OS name: windows 7
  • version: 6.1
  • arch: amd64
1

There are 1 answers

3
Tunaki On

Judging by your configuration, you are using the version of the maven-clean-plugin that is coming from the default binding of the clean lifecycle. This is version 2.5 for Maven 3.3.3.

For this version, there is a bug that the maven-clean-plugin does not respect the followSymLinks attribute on Windows: it is MCLEAN-58:

Maven Clean Plugin ignores followSymLinks parameter on Windows

This has been fixed in version 2.6.1 according to this bug report, for users having Java >= 7, which is your case.

Therefore, you just need to update the version of the maven-clean-plugin you are using to 2.6.1. The current version is 3.0.0 so you might as well update to that one:

<plugin>
   <artifactId>maven-clean-plugin</artifactId>
   <version>3.0.0</version>
   <!-- rest of configuration -->
</plugin>