我想为 Maven 构建传递一些系统变量。如果我使用mvn clean install -Dfirst.variable=value -Dsecond.variable=second.value
一切安好。但这个配置在pom.xml
不起作用:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.3</version>
<executions>
<execution>
<id>tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<systemPropertyVariables>
<first.variable>${value}</first.variable>
<second.variable>${second.value}</second.variable>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
我尝试使用这个配置而不<id/>
, <phase/>
and <goals>
但这没有帮助。插件有没有可能无法运行?即使这些变量的硬编码值也不会通过。如果是这样,可能的解决方案是什么?提前致谢。
您不需要创建一个<execution/>
。最简单的方法:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<my.property>propertyValue</my.property>
</systemPropertyVariables>
</configuration>
</plugin>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)