Maven命令不排除任何内容,尽管排除了pom中的条目

时间:2018-12-04 05:57:03

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

尽管<exclude>文件中surefire插件配置下有pom.xml条条目,哪个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>

1 个答案:

答案 0 :(得分:2)

将配置文件添加到您的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