I’m using the maven-assembly-plugin to produce a zip file for some database scripts. I am having an intermittent problem in that if my build fails for whatever reason, when I come to rebuild it often (but not always) fails immediately when trying to delete the target directory. The reason for this is that the zip assembly file (used by maven-assembly-plugin) that it has copied there is locked.
If I repeatedly try to build, or leave a long enough period between the failed build and a rebuild, the lock is eventually dropped and the build proceeds as normal.
This is proving very frustrating – any ideas what the problem might be? I am using Windows XP Pro.
My pom.xml snippet is :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptors>
<descriptor>src/main/sql/zip-assembly.xml</descriptor>
</descriptors>
<finalName>db-deployment</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-database-scripts</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
Thanks!
Using ‘process explorer’ I can see that there is a java process that still holds onto this file handle even though the maven build has failed. This java process is actually owned by eclipse which is interesting as my build is running from the command line. I suspect that eclipse has seen a file change in the workspace and decided to update its project. After eclipse has finished doing the update, the handle is dropped and my build is able to continue without problem.
Looking further I can see that the assembly file is being built under the main/ directory, which would confirm why eclipse would get involved. I’ll move it!