运行 maven-clean-plugin 在 pre-integration-test 期间没有清除默认目标目录
Running maven-clean-plugin during pre-integration-test without cleaning default target directory
在我的项目中,模块 C 有 parent B,其中有 parent A。
parent一个pom
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
parent B pom
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-extra-files</id>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>C:\foo\bar</directory>
<includes>
<include>foo*.jar</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
模块 C pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-extra-files</id>
<phase>pre-integration-test</phase>
</execution>
</executions>
</plugin>
当我运行mvn clean pre-integration-test
[INFO] --- maven-clean-plugin:3.0.0:clean (clean-extra-files) @ foo-c ---
[INFO] Deleting C:\dev\workspace\foo-a\foo-b\foo-c\target
[INFO] Deleting C:\foo\bar (includes = [foo*.jar], excludes = [])
默认目标目录和我的附加目录都被清理了。但是,我只想清理附加目录。
如何防止clean-extra-files
清除默认目标目录?
如果无法清除不需要的文件,还有哪些其他选项?
环境:Java:6、Eclipse:Luna、Maven:3.2
我相信有一个 "excludes" 标签可以使用。
<fileset>
<directory>some/relative/path</directory>
<includes>
<include>**/*.tmp</include>
<include>**/*.log</include>
</includes>
<excludes>
<exclude>**/important.log</exclude>
<exclude>**/another-important.log</exclude>
</excludes>
<followSymlinks>false</followSymlinks>
</fileset>
http://maven.apache.org/plugins/maven-clean-plugin/examples/delete_additional_files.html
http://maven.40175.n5.nabble.com/How-to-delete-a-directory-td123552.html
这似乎不是使用 maven-clean-plugin 来完成的方法,所以我使用了受 this post 启发的 antrun 任务:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>delete-install-files</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete>
<fileset dir="C:\foo\bar"
includes="foo*.jar" />
</delete>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
在我的项目中,模块 C 有 parent B,其中有 parent A。
parent一个pom
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
parent B pom
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-extra-files</id>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>C:\foo\bar</directory>
<includes>
<include>foo*.jar</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
模块 C pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-extra-files</id>
<phase>pre-integration-test</phase>
</execution>
</executions>
</plugin>
当我运行mvn clean pre-integration-test
[INFO] --- maven-clean-plugin:3.0.0:clean (clean-extra-files) @ foo-c ---
[INFO] Deleting C:\dev\workspace\foo-a\foo-b\foo-c\target
[INFO] Deleting C:\foo\bar (includes = [foo*.jar], excludes = [])
默认目标目录和我的附加目录都被清理了。但是,我只想清理附加目录。
如何防止clean-extra-files
清除默认目标目录?
如果无法清除不需要的文件,还有哪些其他选项?
环境:Java:6、Eclipse:Luna、Maven:3.2
我相信有一个 "excludes" 标签可以使用。
<fileset>
<directory>some/relative/path</directory>
<includes>
<include>**/*.tmp</include>
<include>**/*.log</include>
</includes>
<excludes>
<exclude>**/important.log</exclude>
<exclude>**/another-important.log</exclude>
</excludes>
<followSymlinks>false</followSymlinks>
</fileset>
http://maven.apache.org/plugins/maven-clean-plugin/examples/delete_additional_files.html
http://maven.40175.n5.nabble.com/How-to-delete-a-directory-td123552.html
这似乎不是使用 maven-clean-plugin 来完成的方法,所以我使用了受 this post 启发的 antrun 任务:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>delete-install-files</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete>
<fileset dir="C:\foo\bar"
includes="foo*.jar" />
</delete>
</tasks>
</configuration>
</execution>
</executions>
</plugin>