【发布时间】:2021-03-24 11:52:32
【问题描述】:
我的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>
我希望此配置文件再次执行,系统属性 isValid 是 true
当我复制此配置文件配置并使用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>
但我不知道如何使用 xml-maven-plugin
在<execution> 中设置系统变量和<suiteXmlFile> 属性
我需要使用什么插件来实现我的要求?
有没有办法使用系统属性 isValid 等于 true 和 false 并使用不同的 <suiteXmlFile> 值(不同的 testng 文件)同时运行这两个配置文件?
【问题讨论】:
标签: java maven build maven-2 maven-3