4

If, in my maven project's parent pom.xml, it has some property like this:

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

Is it possible in the child to somehow just "augment" that, like

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

Similarly for say, plugin settings, wish I could do something like

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

I am basically just adding to some setting specified in the parent?

The impetus for this question is I'm wondering how to use the jacoco plugin, and, in the root pom specify some general settings "-Xmx1G" while in the children they can add other child specific parameters to that general one, where necessary. ref: https://stackoverflow.com/a/29975159/32453

I suppose I could just rename the parameter jacoco generates (https://stackoverflow.com/a/25571295/32453 "propertyName" setting, to change it from argLine) and then I could use the parent's ${argLine} and add it to the jacococ one, but my question is still interesting...

rogerdpack
  • 62,887
  • 36
  • 269
  • 388

4 Answers4

1

Property should be directly to visible in your child's pom: ${argLine}

alexey
  • 622
  • 4
  • 9
  • unfortunately if I use `${argLine} child parameters` it responds with this error: `${argLine}': Detected the following recursive expression cycle in 'argLine':` – rogerdpack Apr 30 '15 at 21:18
  • May be this error relates with a thing that your property calls like a maven variable http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#argLine. Try to rename it. – alexey May 01 '15 at 05:35
0

Use pluginMagement in your parent pom and specify there configs. They will be common for all modules in the parent.

win_wave
  • 1,498
  • 11
  • 9
  • I suppose I could set a property in the parent that is named something *else* then reference it in the parent as the "right name" as well, then if I ever need to modify it in a child, reference the original like ${parentArgLine} myArgs. Interesting. This still adds a few more hoops than I'd like to go through, however (you have to know what it was called in the parent, etc.) but interesting! – rogerdpack Apr 30 '15 at 21:02
0

With Maven 3 you can use ${project.parent.propertyName} link

  • 1
    On paper that looks perfect, like "it should just work" but I haven't had any luck actually getting it to do so (maven 3.2) do you have any small examples that might show it working? thanks! – rogerdpack Apr 30 '15 at 21:10
0

The only way I could think of to do this would be to duplicate the parameter in the parent.

so parent:

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

Then use

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

in child.

The problem in my particular case is that a plugin "overrides" a maven variable.

rogerdpack
  • 62,887
  • 36
  • 269
  • 388
  • I wonder if you could add another level in the hierarchy to create said duplication, as well...haven't tried it... – rogerdpack Jan 27 '20 at 19:06