zap*_*pee 7 java maven-3 maven maven-surefire-plugin
我一起使用maven-surefire-plugin+ Sonar,我想argLine为maven-surefire-plugin的参数添加一些额外的值。
所以我做到了:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<argLine>-DCRR.Webservice.isSimulated=true -D...</argLine>
</configuration>
</plugin>
...
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
但是在这种情况下,我将覆盖argLine参数的原始值,Sonar不会生成jacoco.exec文件。
我可以在Maven调试日志(-X)中看到argLine参数的值是,而没有覆盖它的值-javaagent:/opt/jenkins/.../myproject-SONAR/.repository/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128-runtime.jar=destfile=/opt/jenkins/.../myproject-SONAR/target/jacoco.exec。
追加此参数原始值的正确方法是什么(保留原始值+添加其他值)?
我正在使用Apache Maven 3.5.0,Java版本:1.8.0_131,供应商:Oracle Corporation。
zap*_*pee 12
官方文件称该更换较晚。
如果执行以下操作,则将覆盖argLine之前由其他插件设置的参数值,因此请勿这样做:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-D... -D...</argLine>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
保留现有值和添加配置的正确方法是使用@{...}语法:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -D... -D...</argLine>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
或者您可以在文件argLine中将其设置为:propertypom.xml
<properties>
<argLine>-DCRR.Webservice.isSimulated=true -D...</argLine>
</properties>
Run Code Online (Sandbox Code Playgroud)
以上两种解决方案均能正常工作。
Vol*_*ozo 11
更新为Apache Maven 3.8.3.
就我而言,只有 @zapee 建议的组合才有效,换句话说,添加<argLine/>到<properties>配置@{argLine}部分很重要。例子:
<properties>
<!-- This is required for later correct replacement of argline -->
<argLine/>
</properties>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -D... -D...</argLine>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
希望,它对某人有帮助。
| 归档时间: |
|
| 查看次数: |
6104 次 |
| 最近记录: |