【问题标题】:Maven command to exclude nothing despite exclude entry in pom尽管在 pom 中排除条目,但 Maven 命令不排除任何内容
【发布时间】:2019-05-05 12:03:12
【问题描述】:

尽管pom.xml 文件中的surefire 插件配置下有<exclude> 条目,但哪个maven 命令可用于执行所有测试?

例如 - 以下是来自 pom.xml 的部分,但我不想排除 TestA.java。可以使用哪个maven命令?

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <excludes>
        <exclude>**/TestA.java</exclude>
    </excludes>
 </configuration>
</plugin>

【问题讨论】:

  • “通过 maven 命令”是什么意思?另一种方法是什么?
  • 已对问题进行了编辑以使其更加清晰。如果还不清楚,请在此处发布。

标签: maven maven-3 maven-plugin maven-surefire-plugin


【解决方案1】:

将配置文件添加到您的 pom.xml

<profiles>
    <profile>
        <id>all-tests</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <exclude></exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

此配置文件会覆盖 surefire 插件的排除部分。 只需通过以下方式激活配置文件:

mvn clean install -Pall-tests

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-21
    • 2016-04-11
    • 1970-01-01
    • 2012-09-10
    • 1970-01-01
    • 2011-05-11
    • 2011-06-17
    • 2020-02-24
    相关资源
    最近更新 更多