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

I have a multi-module assembly maven, where for one of the child modules an additional goal is required to execute as part of the release. But it looks like any configuration of the maven-release plugin module in the child module is ignored in favor of the default configuration in the parent module.

This is a snippet from a child module. The plugin configuration is the same in the pluginManagement section of the parent pump, but without the user 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> 

. Is it possible for a child module to override the parent configuration and add additional goals?

Maven Version 2.2.1

+8
maven maven-2 maven-release-plugin
source share
2 answers

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> 

Baby 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 more details.

+11
source share

Yes and no. Of course, the child pom can override the configuration of the plugin indicated by its parent, and I have to assume that you did it right, because there is nothing complicated about it. If you check the output of mvn help:effective-pom , you should clearly see that this module has different settings for the release plugin.

The problem you are facing is related to the behavior of the release plugin. Typically, if you run a target or phase - mvn compile , for example - from the root module of your project, it first runs this target / phase on the root module, and then on all modules in the reactor order, almost as if you run it in each module by yourself. Any settings added to child modules take effect as expected. When launching the release plugin, it runs only in the root module. It does not start in any of the child modules. Instead, running it in the root module creates a new assembly using the same settings as the root module, which works for all other modules in much the same way, except that it uses the root module configuration for all modules. I don’t know the exact semantics, but I believe that this is similar to how you manually launch release targets in each child element and specify configuration parameters as system properties on the command line: no matter how the child module configures the release plugin, Command line args wins.

I have never dealt with this problem myself, and it’s hard to say without knowing exactly what you are trying to achieve. Perhaps if you can express what you want to do in this special module as a profile, then you can add the profile to goals and / preparationGoals . Alternatively, arguments an option for both preparing and completing goals for which you could perform some tricks.

+2
source share

All Articles