maven- assembly-plugin 锁定文件
我正在使用 maven-assemble-plugin 为某些数据库脚本生成 zip 文件。我遇到一个间歇性的问题,如果我的构建由于某种原因失败,当我尝试删除目标目录时,当我重建它时,它经常(但并非总是)立即失败。原因是它复制到的 zip 程序集文件(由 maven- assembly-plugin 使用)被锁定。
如果我反复尝试构建,或者在失败的构建和重建之间留出足够长的时间,锁最终会被删除,构建会正常进行。
事实证明这非常令人沮丧——你知道问题可能是什么吗?我使用的是 Windows XP 专业版。
我的 pom.xml 片段是:
<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>
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用“进程资源管理器”,我可以看到有一个 java 进程仍然保留着这个文件句柄,即使 Maven 构建失败了。这个java进程实际上是由eclipse拥有的,这很有趣,因为我的构建是从命令行运行的。我怀疑 Eclipse 在工作区中发现了文件更改并决定更新其项目。 Eclipse 完成更新后,句柄被删除,我的构建能够继续,没有问题。
进一步看,我可以看到程序集文件正在 main/ 目录下构建,这将证实为什么 eclipse 会参与其中。我来搬一下!
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!