Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 435
KevinS Avatar asked Jun 10 '11 12:06

KevinS


People also ask

How do I override plugin from parent pom?

Overriding configurations from a parent pom can be done by adding the combine. self="override" attribute to the element in your pom. It appears that for Maven2. 2.1 if you do this in a profile it doesn't merge with plugins defined in parent profiles but overrides them.

How to configure Maven plugin in POM xml?

Next, open the command console and go to the folder containing pom. xml and execute the following mvn command. Maven will start processing and displaying the clean phase of clean life cycle. Plugins are specified in pom.

Are plugins inherited from parent pom?

1. Overview. Maven allows us to build a project using the concept of inheritance. When a parent POM defines a plugin, all of the child modules inherit it.


Video Answer


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

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

like image 67
Prashant Bhate Avatar answered Sep 22 '22 18:09

Prashant Bhate