Configuration inheritance regarding the Maven Shade Plugin

1.2k views Asked by At

Currently I have problems with the configuration inheritance of the Maven Shade Plugin, what I mean by this is that artifactSet and all configuration options "underneath" it turn red whenever I remove the phase and goals options (which are meant to be inherited from the parents pluginManagement section.

I'll show what I have in my parent first and after that what I'm trying to accomplish.

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>

                <executions>
                    <execution>
                        <phase>package</phase>

                        <goals>
                            <goal>shade</goal>
                        </goals>

                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            <plugin>
        </plugins>
    </pluginManagement>
</build>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>

                <executions>
                    <execution>
                        <configuration>
                            <artifactSet>
                                <includes>
                                    <include>...</include>
                                </includes>
                            </artifactSet>
                        </configuration>
                    </execution>
                </executions>
            <plugin>
        </plugins>
    </pluginManagement>
</build>
1

There are 1 answers

8
Naman On

1 - You are missing a type <execution> here -

Change

<executions>
    <phase>package</phase>
    <goals>
       <goal>shade</goal>
    </goals>
    <configuration>
       <createDependencyReducedPom>false</createDependencyReducedPom>
    </configuration>
</executions>

to

<executions>
    <execution>
        <phase>package</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <configuration>
            <createDependencyReducedPom>false</createDependencyReducedPom>
        </configuration>
    </execution>
</executions>

2 - To inherit the configuration from the parent pom.xml, you need to make sure the child pom doesn't define the plugin again within <pluginManagement>. You can remove the tag to inherit the configuration from the parent.