我有一个专家问题。
我有一个生成临时目录 gwt-unitCache 文件夹的 GWT 项目。我想在构建过程结束时将其删除。
我有这个插件配置:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>src/main</directory>
<includes>
<directory>gwt-unitCache/**</directory>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
<executions>
<execution>
<id>gwt-unitCache</id>
<phase>install</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
这通过删除 src/main 下自动生成的 gwt-unitCache 文件夹来完成它的工作。但是,它也删除了包含类和 war 文件的目标文件夹。
我不想删除目标文件,因此我通过删除以下部分修改了配置:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>src/main</directory>
<includes>
<directory>gwt-unitCache/**</directory>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
<executions>
<execution>
<id>gwt-unitCache</id>
<phase>install</phase>
</execution>
</executions>
</plugin>
但是这次不行了。 gwt-unitCache 没有被删除。看起来插件是在构建过程的开始而不是结束时运行的。
我不擅长 Maven。有人可以帮忙吗?我如何配置它以便:
- gwt-unitCache 在构建过程结束时被删除。
- 目标文件夹未被删除。
我使用命令: maven 全新安装
构建它。
非常感谢。
最佳答案
未测试但maven-clean-plugin
公开一个可以帮助完成这项工作的 excludeDefaultDirectories
。像这样的东西:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>src/main</directory>
<includes>
<directory>gwt-unitCache/**</directory>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
</configuration>
<executions>
<execution>
<id>gwt-unitCache</id>
<phase>install</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
附带说明一下,我不明白你为什么需要清除这个目录,你不能在你的 SCM 中忽略它吗?
关于java - Maven:清理 gwt-unitCache 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15452040/