Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does maven handle duplicate plugin declaration

A large undocumented project whose build I am trying to cleanup has maven warnings about duplicate plugin declaration.

The pom.xml is something like

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webResources>
      <resource>
        <directory>${project.basedir}/src/main/webapp</directory>
      </resource>
    </webResources>
  </configuration>
</plugin>

<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <attachClasses>true</attachClasses>
    <classesClassifier>classes</classesClassifier>
  </configuration>
</plugin>

I need to change it so it does not log warnings yet behaves exactly as it does now.

I guess, there are three possibilities:

  • first declaration wins
  • last declaration wins
  • all encountered declarations are merged XML-wise

But which one is it?

like image 983
bobah Avatar asked Nov 08 '22 12:11

bobah


1 Answers

Run with debug logging (-X), find the occurrences/mentions of the war plugin in the log, and see what configuration is present. Then make your POMs look like that configuration.

like image 75
user944849 Avatar answered Dec 04 '22 00:12

user944849