简体   繁体   English

在集成前测试期间运行maven-clean-plugin而不清理默认目标目录

[英]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.

相关问题 使用maven-clean-plugin删除目录 - Remove directory with maven-clean-plugin 在Eclipse中运行需要Maven预集成测试执行的JUnit集成测试? - Running JUnit integration tests in Eclipse that need Maven pre-integration-test executions? 更改Maven故障安全预集成测试的工作目录以查找Spring配置 - Change working directory for Maven failsafe pre-integration-test to find Spring configuration Jetty不在集成前测试阶段(Maven)开始 - Jetty doesn't start in pre-integration-test phase (Maven) maven-clean-plugin不删除文件 - maven-clean-plugin not delete files 如何解决“无法在项目上执行目标 org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean)”? - How to solve "Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project"? 运行Maven项目的多个“实例”-无法执行目标org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean - Running multiple 'instances' of maven project - Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean Maven的困境:在存储库中找不到maven-clean-plugin - Maven woes: maven-clean-plugin not found in repository 无法在预集成测试阶段启动Jetty - Not able to start Jetty in pre-integration-test phase maven-clean-plugin或其中一个依赖项无法解决 - maven-clean-plugin or one of its dependencies could not be resolved
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM