我正在尝试基于通过命令行发送的另一个属性来设置Maven属性值。
<profiles>
<profile>
<id>desktop</id>
<activation>
<property>
<name>environment</name>
<value>desktop</value>
</property>
</activation>
<properties>
<qTest.testCycleId>XXXXXX</qTest.testCycleId>
</properties>
</profile>
</profiles>
当我尝试在如下所示的一个插件中使用qTest.testCycleId时,出现属性未解析错误。
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>Upload Results to qTest</id>
<phase>post-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${script.executor}</executable>
<commandlineArgs>${basedir}/scripts/qTest/QTestUploaderCucumber.sh
${basedir}
${qTest.testCycleId} ${qTest.projectId}
</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
PS-如果根据如下所示的os系列激活了配置文件,则可以正确解析属性。
<profile>
<id>Windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<qTest.testCycleId>XXXXXX</qTest.testCycleId>
</properties>
</profile>
编辑:根据要求,请找到命令行
mvn verify -DSUT=uat -Denvironment=desktop -DBrowser=chrome "-Dcucumber.options=--tags @Temp" -DforkCount=0 -e
提前感谢。
最终发现这是由于Intellij中的设置所致。我必须选中Maven配置文件下的环境复选框。