Suppose I have the three following maven modules :
- parent
- heir (submodule of parent, parent is its parent)
- extern (other project, parent is its parent)
I would like to configure plugins only for parent and its submodules (parent and heir in my example) without any side effect for external projects (extern in this case).
parent defines a plugin in pluginManagement, for example :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>hello, heir</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>echo</executable>
<arguments>
<argument>Hello, heir!</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Unfortunately, this plugin configuration will have a side effect on extern. See, if extern defines the following, the above configuration will apply to him :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
...
</plugin>
Now, how can change my project structure or pom configuration so that :
- I can build my whole project from a single command on one pom
- I can deploy my whole project from a single command on one pom
- I can define plugins for internal use only (parent pom and its submodules) / An external project will not inherit from these plugins
- Said plugins are still inherited from internal plugins
?
CodePudding user response:
You need to change the hierarchy to
- external-parent
- parent
- submodules