[英]Running maven-clean-plugin during pre-integration-test without cleaning default target directory
In my project, module C has parent B which has parent A. 在我的项目中,模块C的父级B具有父级A。
parent A 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 父母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>
module C pom 模块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>
When I run mvn clean pre-integration-test
当我运行
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 = [])
Both the default target directory and my additional directory are cleaned. 默认目标目录和我的其他目录都被清除。 However, I only want the additional directory cleaned.
但是,我只希望清除其他目录。
How do I prevent clean-extra-files
from cleaning the default target directory? 如何防止
clean-extra-files
清理默认目标目录?
If it is not possible, what other options are there for cleaning up unwanted files? 如果不可能,还有哪些其他选项可以清除不需要的文件?
Env: Java:6, Eclipse:Luna, Maven:3.2 环境:Java:6,Eclipse:Luna,Maven:3.2
I believe there is an "excludes" tag which you can use. 我相信您可以使用一个“排除”标签。
<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.apache.org/plugins/maven-clean-plugin/examples/delete_additional_files.html
http://maven.40175.n5.nabble.com/How-to-delete-a-directory-td123552.html http://maven.40175.n5.nabble.com/How-to-delete-a-directory-td123552.html
It doesn't seem to be a way to do it with the maven-clean-plugin, so I used an antrun task inspired by this post : 这似乎不是使用maven-clean-plugin的方法,所以我使用了受本文启发的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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.