Maven – Parent Pom – Child Inheritance

maven

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>

Best Answer

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