【问题标题】:Is it possible to pass optional parameter testIncludes or testExcludes to maven compile plugin through the command line?是否可以通过命令行将可选参数 testIncludes 或 testExcludes 传递给 Maven 编译插件?
【发布时间】:2015-09-21 08:06:46
【问题描述】:
  1. 是否可以通过命令行将可选参数testIncludes或testExcludes传递给maven编译插件?
    我需要传递一些 .java 作为可选参数。


类似

mvn clean verify test-compile -DtestIncludes=**/course/MyTest.java,**/course/CompileMeWithMyTest.java,etc

在页面http://maven.apache.org/plugins/maven-compiler-plugin/testCompile-mojo.html testIncludes 和 testExcludes 没有提到用户属性


测试包括:
编译器的包含过滤器列表。
类型:java.util.Set
自:2.0
必填:否

测试不包括:
编译器的排除过滤器列表。
类型:java.util.Set
自:2.0
必填:否

  1. 如果问题 1 没有任何可能的变体。 是否可以使用命令行以某种方式在下一个配置文件中设置包含/排除 java 类/文件夹。

     <profile>
        <id>only-necessary-classes</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <source>${java-version}</source>
                        <target>${java-version}</target>
                    </configuration>
                    <executions>
                        <execution>
                            <id>default-testCompile</id>
                            <phase>test-compile</phase>
                            <configuration>
                                <testIncludes>
                                    <include>**/tests/projectname/course/CheckQuizWithNewAccount.java</include>
                                    <include>**/tests/projectname/course/V8GenericTests.java</include>
                                </testIncludes>
                            </configuration>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    

【问题讨论】:

    标签: java maven maven-3 maven-compiler-plugin


    【解决方案1】:

    创建您自己的属性并在 testIncludes\testExcludes 块中使用它。

    mvn clean verify -Dinclude=**/course/MyTest.java

    <properties>
        <include>some test</include>
    </properties>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
                <executions>
                    <execution>
                        <id>default-testCompile</id>
                        <phase>test-compile</phase>
                        <configuration>
                            <testIncludes>
                                <include>${include}</include>
                            </testIncludes>
                        </configuration>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    【讨论】:

    • 感谢您的回答,如果我需要通过 2 或移动测试以包含部分怎么办?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-07
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    • 1970-01-01
    • 2015-09-14
    • 2022-11-29
    相关资源
    最近更新 更多