rve
rve

Reputation: 6055

Specify which maven build plugins to use in a parent pom

I have a couple of projects, all using the same plugins in the build section. Is it possible to specify which plugins to run inside the build section in a central place?

I know you can put the plugin configuration in a parent poms pluginManagement section, but then you still have to list all plugins in the build section.

For example I want something like:

parent.pom

<pluginManagement>
  <plugins>
    <plugin>
      <artifactId>plugin1</artifactId>
      ...
    </plugin>
    <plugin>
      <artifactId>plugin2</artifactId>
      ...
    </plugin>
  </plugins>
</pluginManagement>

child.pom

<build>
    <include-plugins-from-parent-without-listing-plugin1-and-plugin2/>
</build>

Also, I would like to do the same thing with reports. Define in a single file which reports to run and include this in every other project.

Update: any other way of synchronizing the same build settings between multiple projects is fine too. I just do not want to copy&paste the same stuff in all POM files.

Upvotes: 0

Views: 1436

Answers (1)

Fabricio Lemos
Fabricio Lemos

Reputation: 2955

Inside parent.pom declare the plugins inside <build>\<plugins> instead of <pluginManagement>:

<build>
  <plugins>
    <plugin>
      <artifactId>plugin1</artifactId>
      ...
    </plugin>
 </plugins>
</build>

Upvotes: 2

Related Questions