如何用不同的系统属性值执行两个完全相同的maven概要文件?

jyztefdp  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(226)

我有下面提到的实现在我的 pom 文件

<profile>
        <id>test</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <property>
                <name>test</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>xml-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>transform</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <transformationSets>
                            <transformationSet>
                                <includes>
                                    <include>set.xml</include>
                                </includes>
                                <dir>test/resources/</dir>
                                <stylesheet>
                                    test/resources/ser.xsl
                                </stylesheet>
                                <outputDir>test/resources</outputDir>
                            </transformationSet>
                        </transformationSets>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>net.sf.saxon</groupId>
                            <artifactId>saxon</artifactId>
                            <version>8.7</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.1</version>
                    <inherited>false</inherited>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>testng.xml</suiteXmlFile>
                        </suiteXmlFiles>
                        <systemProperties>
                            <property>
                                <name>maven.test.haltafterfailure</name>
                                <value>false</value>
                            </property>
                            <property>
                                <name>java.io.tmpdir</name>
                                <value>${basedir}/target/</value>
                            </property>
                            <property>
                                <name>isValid</name>
                                <value>false</value>
                            </property>
                        </systemProperties>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

我想用系统属性再次执行此配置文件 isValidtrue 当我复制这个配置文件并用 isValid 等于 true 正在覆盖第一个配置文件配置。
从maven文档。。。
除非使用前面描述的方法之一激活同一pom中的另一个概要文件,否则此概要文件将自动对所有生成激活。当pom中的配置文件在命令行或通过其激活配置激活时,默认情况下处于活动状态的所有配置文件都将自动停用。。。
我尝试添加两个执行,如下所示:

<executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>transform</goal>
                            </goals>
                            <configuration>.... </configuration>
                        </execution>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>transform</goal>
                            </goals>
                            <configuration>.... </configuration>
                        </execution>
                    </executions>

但我不知道如何设置系统变量和 <suiteXmlFile> 内部财产 <execution> 使用xml maven插件
我需要使用什么插件来达到我的要求?
有没有办法运行这两个配置文件的系统属性isvalid等于 true 以及 false 用不同的 <suiteXmlFile> 值(不同的testng文件)?

lnxxn5zx

lnxxn5zx1#

如果复制概要文件,那么就定义同一个插件两次,这样配置就会被覆盖。
相反,定义两个 <executions> 相同的插件。

相关问题