Uploaded image for project: 'Maven Clean Plugin'
  1. Maven Clean Plugin
  2. MCLEAN-28

maven-clean-plugin doesn't delete directories with symlinks in them

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2
    • 2.3
    • None
    • maven 2.0.7, Ubuntu 7.10, Intel Pentium M

    Description

      Note: this issue did not happen with maven-2.0.4 and maven-clean-plugin 2.1.1.

      I have a maven project for a JNI library wrapping several shared libs. For testing, the shared libs are unpacked into target/tmplib, and the maven-surefire-plugin gets a LD_LIBRARY_PATH enviroment variable setting pointing to this directory.

      The shared libs are unpacked in a manner that preserves their symbolic links, eg.
      lrwxrwxrwx 1 sb sb 17 Dec 23 22:00 libxml2.so -> libxml2.so.2.6.23
      lrwxrwxrwx 1 sb sb 17 Dec 23 22:00 libxml2.so.2 -> libxml2.so.2.6.23
      rwxr-x-- 1 sb sb 3104024 Nov 28 13:23 libxml2.so.2.6.23
      lrwxrwxrwx 1 sb sb 13 Dec 23 22:00 libz.so -> libz.so.1.2.3
      lrwxrwxrwx 1 sb sb 13 Dec 23 22:00 libz.so.1 -> libz.so.1.2.3
      rwxr-x-- 1 sb sb 168053 Nov 28 13:08 libz.so.1.2.3

      When doing "mvn clean" it refuses to delete target/tmplib (see the error message with stack trace below), and when I inspect the target/tmplib directory, it contains only symlinks. The files they point to have been removed. Using the example above, it now looks like:
      lrwxrwxrwx 1 sb sb 17 Dec 23 22:00 libxml2.so -> libxml2.so.2.6.23
      lrwxrwxrwx 1 sb sb 17 Dec 23 22:00 libxml2.so.2 -> libxml2.so.2.6.23
      lrwxrwxrwx 1 sb sb 13 Dec 23 22:00 libz.so -> libz.so.1.2.3
      lrwxrwxrwx 1 sb sb 13 Dec 23 22:00 libz.so.1 -> libz.so.1.2.3

      The error message with stack trace, looks like this:
      [INFO] [clean:clean]
      [INFO] Deleting directory /home/sb/p4/depot/someproj/MAIN/com.somecompany.someproj.somejnilib/target
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Failed to delete directory: /home/sb/p4/depot/someproj/MAIN/com.somecompany.someproj.somejnilib/target. Reason: Unable to delete directory /home/sb/p4/depot/someproj/MAIN/com.somecompany.someproj.somejnilib/target/tmplib

      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to delete directory: /home/sb/p4/depot/someproj/MAIN/com.somecompany.someproj.somejnilib/target. Reason: Unable to delete directory /home/sb/p4/depot/someproj/MAIN/com.somecompany.someproj.somejnilib/target/tmplib
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:564)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to delete directory: /home/sb/p4/depot/someproj/MAIN/com.somecompany.someproj.somejnilib/target. Reason: Unable to delete directory /home/sb/p4/depot/someproj/MAIN/com.somecompany.someproj.somejnilib/target/tmplib
      at org.apache.maven.plugin.clean.CleanMojo.removeDirectory(CleanMojo.java:265)
      at org.apache.maven.plugin.clean.CleanMojo.execute(CleanMojo.java:173)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:443)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
      ... 16 more
      Caused by: java.io.IOException: Unable to delete directory /home/sb/p4/depot/someproj/MAIN/com.somecompany.someproj.somejnilib/target/tmplib
      at org.apache.maven.shared.model.fileset.util.FileSetManager.removeDir(FileSetManager.java:599)
      at org.apache.maven.shared.model.fileset.util.FileSetManager.removeDir(FileSetManager.java:574)
      at org.apache.maven.shared.model.fileset.util.FileSetManager.delete(FileSetManager.java:309)
      at org.apache.maven.plugin.clean.CleanMojo.removeDirectory(CleanMojo.java:261)
      ... 19 more
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 2 seconds
      [INFO] Finished at: Sun Dec 23 22:02:09 CET 2007
      [INFO] Final Memory: 8M/16M
      [INFO] ------------------------------------------------------------------------

      Compilation exited abnormally with code 1 at Sun Dec 23 22:02:11

      Attachments

        Issue Links

          Activity

            People

              bentmann Benjamin Bentmann
              steinarb Steinar Bang
              Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: