- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 maven-surefire-plugin
+ Sonar
一起使用,我想向 maven 的 argLine
参数添加一些额外的值-surefire-插件。
所以我做到了:
<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 文件。
我可以在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。
最佳答案
官方文档称late replacement .
如果您执行以下操作,您将覆盖之前由其他插件设置的 argLine
参数的值,因此不要这样做:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-D... -D...</argLine>
</configuration>
</plugin>
保留现有值并添加配置的正确方法是使用 @{...}
语法:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -D... -D...</argLine>
</configuration>
</plugin>
或者您可以在 pom.xml
文件中将 argLine
设置为 property
:
<properties>
<argLine>-DCRR.Webservice.isSimulated=true -D...</argLine>
</properties>
以上两种解决方案都可以正常工作。
关于java - 在 maven-surefire-plugin 中附加 argLine 参数的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46489455/
我有 2 个配置文件,可能会也可能不会一起使用来运行一组测试。它们每个都需要不同的 vmargs 才能运行,但如果它们一起使用,可以将它们相互附加。 我正在寻找的是一种将 argLine 设置为其当前
我有一套现有的 Karate 测试,可以使用以下方法在不同的环境(开发/质量检查)上运行: mvn test -DargLine="-DauthUser=*** -DauthPassword=***
我正在使用 maven-surefire-plugin + Sonar 一起使用,我想向 maven 的 argLine 参数添加一些额外的值-surefire-插件。 所以我做到了:
在 Eclipse 中,我执行“Run As”、“Maven test”或“Maven build”,但测试失败。在“运行配置”中,我将目标设置为 clean package -DargLine="-
我是一名优秀的程序员,十分优秀!