Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

maven

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 ?

like image 794
hawarden_ Avatar asked Nov 17 '25 14:11

hawarden_


1 Answers

...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:effective-pom -P myProfile,...

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

like image 170
xerx593 Avatar answered Nov 19 '25 08:11

xerx593



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!