我想为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>
Run Code Online (Sandbox Code Playgroud)
我试图用这个配置没有<id/>,<phase/>而<goals>却没有帮助.插件是否有可能无法运行?甚至这些变量的硬编码值也不会通过.如果是这样,什么是可能的解决方案?提前致谢.
你不需要创建一个<execution/>.简单的方法:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<my.property>propertyValue</my.property>
</systemPropertyVariables>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8830 次 |
| 最近记录: |