在maven-surefire-plugin中附加argLine param的值 [英] Append the value of argLine param in maven-surefire-plugin
问题描述
我正在使用 maven-surefire-plugin
+ 声纳
,我想添加一些额外的值 argLine
maven-surefire-plugin的参数。
I am using maven-surefire-plugin
+ Sonar
together and I would like to add some extra value to argLine
parameter of the 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>
但是在这种情况下我会覆盖 argLine的原始值
参数和Sonar不会生成jacoco.exec文件。
But in this case I am overwriting the original value of the argLine
parameter and Sonar does not generate jacoco.exec file.
我可以在maven调试日志(-X)中看到argLine param的值没有覆盖其值为 -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
。
I can see in the maven debug log (-X) that the value of argLine param without overwriting its value is -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
.
APPEND这个参数的原始值的正确方法是什么(保持原始+添加额外值)?
What is the proper way to APPEND the original value of this parameter (keep the original + add extra values)?
我使用的是Apache Maven 3.5.0,Java版本: 1.8.0_131,供应商:Oracle Corporation。
I am using Apache Maven 3.5.0, Java version: 1.8.0_131, vendor: Oracle Corporation.
推荐答案
官方文档称延迟更换。
如果你o以下您将覆盖之前由其他插件设置的 argLine
参数的值,因此请勿这样做:
If you do the following you will overwrite the value of the argLine
parameter which is set by another plugins before, so DO NOT DO THIS:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-D... -D...</argLine>
</configuration>
</plugin>
保持现有值并添加配置的正确方法是使用 @ {...}
语法:
The proper way to keep the existing values and add your configuration is to use @{...}
syntax:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -D... -D...</argLine>
</configuration>
</plugin>
或者您可以将 argLine
设置为<您的 pom.xml
文件中的code> property :
OR you can set argLine
as a property
in your pom.xml
file:
<properties>
<argLine>-DCRR.Webservice.isSimulated=true -D...</argLine>
</properties>
上述两种解决方案都能正常运行。
Both solutions above works properly.
这篇关于在maven-surefire-plugin中附加argLine param的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!