Java 在maven surefire插件中附加argLine param的值

Java 在maven surefire插件中附加argLine param的值,java,maven,maven-3,maven-surefire-plugin,Java,Maven,Maven 3,Maven Surefire Plugin,我正在同时使用maven surefire插件+Sonar,我想为maven surefire插件的argLine参数添加一些额外的值 所以我做到了: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plug

我正在同时使用
maven surefire插件
+
Sonar
,我想为maven surefire插件的
argLine
参数添加一些额外的值

所以我做到了:

<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>

org.apache.maven.plugins
maven surefire插件
2.20.1
-DCRR.Webservice.isSimulated=true-D。。。
...
但在本例中,我覆盖了
argLine
参数的原始值,Sonar不会生成jacoco.exec文件

我可以在maven调试日志(-X)中看到,在不覆盖其值的情况下,argLine param的值是
-javaagent:/opt/jenkins/../myproject SONAR/.repository/org/jacoco/org.jacoco.agent/0.7.4.20150262128/org.jacoco.agent-0.7.4.20150262128-runtime.jar=destfile=/opt/jenkins/../myproject SONAR/target/jacoco.exec

附加此参数原始值的正确方法是什么(保留原始值+添加额外值)


我使用的是ApacheMaven 3.5.0,Java版本:1.8.0,供应商:Oracle Corporation。

官方文档称之为

如果执行以下操作,您将覆盖以前由其他插件设置的
argLine
参数的值,因此不要执行此操作:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <argLine>-D... -D...</argLine>
    </configuration>
</plugin>
或者您可以在
pom.xml
文件中将
argLine
设置为
属性

<properties>
    <argLine>-DCRR.Webservice.isSimulated=true -D...</argLine>
</properties>

-DCRR.Webservice.isSimulated=true-D。。。

上述两种解决方案都能正常工作。

我看不出解决方案中的“附加原始值”在哪里。这是附加该值的方式。将argLine定义为属性,而不是直接将其添加到插件中。当我阅读“APPEND”时,我希望在一个位置出现“-Dfoo=bar”在第二个位置出现“-Dalpha=beta”,并且有一种方法可以得到“-Dfoo=bar-Dalpha=beta”。您描述了如何替换,而不是如何附加。此外,您还写了“不要在标记之间定义argLine:”。为什么不呢?用户属性“argLine”位于插件属性“argLine”之前。也许你的答案是正确的,但请提供具体的例子:jacoco的默认配置以及如何添加“一些额外值”和保留jacoco设置的解决方案。我现在看到的只是将“argLine”从插件配置移动到构建属性。这是一个附加。你查过官方文件了吗?上面写着:“晚更换”。我很困惑,也许我理解错了什么。你能提高答案的可读性吗。例如,一个段落以“Do not define argLine…”开头,下面是一个以“…”开头的片段。该片段是正面示例还是负面示例?我认为最好的解决方案是更具体的答案,带有示例jacoco设置和增加额外价值的方法。此外,您在评论中提到“延迟替换”,但您的回答没有使用语法@{}
<properties>
    <argLine>-DCRR.Webservice.isSimulated=true -D...</argLine>
</properties>