6

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
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Dezmond
  • 61
  • 3
  • 1
    I have the same problem (tried version 2.6.1 and 3.0.0).Using maven 3.3.9, java 1.8.0_112, Windows 10. – Vojta Dec 21 '16 at 15:24
  • Junctions are different from symlinks on Windows: [Determine whether a file is a junction (in Windows) or not?](https://stackoverflow.com/questions/13733275/determine-whether-a-file-is-a-junction-in-windows-or-not) – user11153 Feb 26 '21 at 15:42

1 Answers1

1

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>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • 3
    I have updated version as you adviced. But it doesn't help. – Dezmond Feb 23 '16 at 21:00
  • @Dezmond Then I can't reproduce your problem. I've just tested on a sample project. Could you post your whole log as a pastebin, with the command you ran? – Tunaki Feb 23 '16 at 21:32
  • @Dezmond See this issue: [IO-295 FileUtils.isSymlinks misses symlink folders on Windows](https://issues.apache.org/jira/browse/IO-295) – user11153 Feb 26 '21 at 14:42