How to override maven-release-plugin config in one child module

KevinS picture KevinS · Jun 10, 2011 · Viewed 8.2k times · Source

I have a multi-module maven build where one of the child modules requires an extra goal to be executed as part of a release. But it looks as though any configuration of the maven-release-plugin in the child module is ignored in favour of the default configuration in the parent module.

This is the snippet from the child module. The plugin configuration is the same in the pluginManagement section of the parent pom, but without the custom element.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>    
    <version>2.1</version>
    <configuration>
        <tagBase>http://mycompany.com/svn/repos/myproject/tags</tagBase>
        <goals>deploy myCustomPlugin:myCustomGoal</goals>
    </configuration>
</plugin>

So is it possible for a child module to override the parent's configuration and add extra goals?

Maven version 2.2.1

Answer

Prashant Bhate picture Prashant Bhate · Aug 5, 2011

Use combine.children="append" combine.self="override"

Parent POM

<configuration>
  <items>
    <item>parent-1</item>
    <item>parent-2</item>
  </items>
  <properties>
    <parentKey>parent</parentKey>
  </properties>
</configuration>

Child pom

<configuration>
  <items combine.children="append">
    <!-- combine.children="merge" is the default -->
    <item>child-1</item>
  </items>
  <properties combine.self="override">
    <!-- combine.self="merge" is the default -->
    <childKey>child</childKey>
  </properties>
</configuration>

Result

<configuration>
  <items combine.children="append">
    <item>parent-1</item>
    <item>parent-2</item>
    <item>child-1</item>
  </items>
  <properties combine.self="override">
    <childKey>child</childKey>
  </properties>
</configuration>

See this blog for further details