使用maven可以“添加”到父pom中指定的属性或插件值吗?

问题描述 投票:4回答:4

如果在我的maven项目的父pom.xml中,它具有如下所示的属性:

<properties>
   <argLine>some args</argLine>
</properties>

是否有可能在孩子中以某种方式“增强”,例如

<properties>
   <argLine>${parent.argLine} some more args</argLine>
</properties>

类似地说,插件设置,例如

<build>
   <plugins>
    <plugin>
       <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
            <argLine>${parent.plugin.maven-surefire-plugin.argLine} -Xmx1G</argLine>
          </configuration> 

我基本上只是添加到父项中指定的某些设置?

这个问题的动力是我想知道如何使用jacoco插件,例如,在root pom中指定“ -Xmx1G”,而在子级中可以添加其他参数。参考:https://stackoverflow.com/a/29975159/32453

[我想我可以重命名jacoco生成的参数(https://stackoverflow.com/a/25571295/32453“ propertyName”),然后可以使用父级的$ {argLine}并将其添加到jacococ中,但是我的问题仍然存在。

java maven jacoco
4个回答
1
投票
属性应直接在您孩子的pom中可见:${argLine}

0
投票
在父pom中使用pluginMagement并在其中指定配置。它们对于父级中的所有模块都是通用的。

0
投票
使用Maven 3,您可以使用$ {project.parent.propertyName} link

0
投票
我唯一想到的方法是

duplicate父级中的参数。

所以父母:

<properties> <argLine>some args</argLine> <parentArgLine>some args</parentArgLine> </properties>

然后使用

<properties> <argLine>${parentArgLine} some child args</argLine>

在儿童中。

在我的特定情况下,问题是插件“覆盖”了一个maven变量。

© www.soinside.com 2019 - 2024. All rights reserved.