Home > database >  Maven: is it necessary to put maven-jar-plugin in POM?
Maven: is it necessary to put maven-jar-plugin in POM?

Time:01-11

I found that even without specifying maven-jar-plugin in the POM, when I run mvn package, it will still generate the JAR.

So what is the point to include it as a plugin explicitly in the POM file ?

CodePudding user response:

...the version, or custom configuration/execution, the "default configuration" in Maven:3.8.4 is:

 ...
   <build>
     <plugins>
      <plugin>
        <!-- in maven#plugins we "never" need to write <groupId>org.apache.maven.plugins</groupId> , since this is also "default plugin group id" -->
        <artifactId>maven-jar-plugin</artifactId>  <!-- org.apache.maven:maven-core:3.8.4:default-lifecycle-bindings -->
        <version>2.4</version>  <!-- org.apache.maven:maven-core:3.8.4:default-lifecycle-bindings -->
        <executions>
          <execution>
            <id>default-jar</id>  <!-- org.apache.maven:maven-core:3.8.4:default-lifecycle-bindings -->
            <phase>package</phase>  <!-- org.apache.maven:maven-core:3.8.4:default-lifecycle-bindings -->
            <goals>
              <goal>jar</goal>  <!-- org.apache.maven:maven-core:3.8.4:default-lifecycle-bindings -->
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...

You can "always" find your "implicit" configuration(s) by issuing:

mvn -Doutput=eff.pom.xml -Dverbose=true help:effecitve-pom -P myProfile,...

...and inspection of eff.pom.xml. Ref (or use ' "effective pom" view/tab;)

  •  Tags:  
  • Related