24
votes

I am attempting to make a maven parent pom setup where I don't have to declare any plugin information in my child pom, everything is taken from the parent pom.

I essentially have it working where I've put all my plugins with there configurations in to the parent pom. Then in the child poms I have to declare the plugin still, but without the version and configuration information.

I don't want to have to declare the plugin in the child at all. This way I can add new features (such as pmd, freebugs, etc) to my parent pom and all my projects now have them working. How can I accomplish this?

Parent Pom

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.0</version>
            <inherited>true</inherited>
            <configuration>
                <providerImplementations>
                    <cvs>cvs_native</cvs>
                </providerImplementations>
                <systemProperties>
                    <property>
                        <name>maven.scm.perforce.clientspec.name</name>
                        <value>${perforceClientSpec}</value>
                    </property>
                </systemProperties>
            </configuration>
        </plugin>

Child Pom still needs this but I don't want to have to do this if I can avoid it:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-scm-plugin</artifactId>
</plugin>
3

3 Answers

36
votes

<pluginManagement> section is intended to configure project builds that inherit from this one. However, this only configures plugins that are actually referenced within the plugins element in the children (so you have to explicitly specify them, as you indicated). See more here.

If you want to avoid this, you can put this information into <build> section like this:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-scm-plugin</artifactId>
      <version>1.0</version>
      <configuration>
        <...>
      </configuration>
      <executions>
        <...>
      </executions>
    </plugin>
  </plugins>
</build>
15
votes

Instead of using pluginManagement, try using just <plugins> tag. It should be auto inherited. You may optionally override configuration in child pom. Check that by mvn help:effective-pom

0
votes

You can't avoid naming the plugin in the child pom, cause how should maven know which plugin are you using. The pluginManagement section is intended for defining the versions of plugin furthermore it's used to define a default configuration.