You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/06/13 19:13:08 UTC

(maven-jar-plugin) branch master updated (7c6ea2d -> f631e64)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git


    from 7c6ea2d  Bump org.apache.maven.plugins:maven-plugins from 47 to 48
     new b28cf10  MJAR: Fix NullPointerException in AbstractJarMojo by increasing field visibility and adding fallbacks
     new f631e64  MJAR: Increase visibility of @Inject fields to protected to ensure proper injection in Maven 4

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/maven/plugins/jar/AbstractJarMojo.java  | 40 +++++++++++++---------
 1 file changed, 23 insertions(+), 17 deletions(-)


(maven-jar-plugin) 01/02: MJAR: Fix NullPointerException in AbstractJarMojo by increasing field visibility and adding fallbacks

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git

commit b28cf109184b9836458a12d35eb9d22f3bca8395
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Jun 13 20:14:09 2026 +0200

    MJAR: Fix NullPointerException in AbstractJarMojo by increasing field visibility and adding fallbacks
---
 .../apache/maven/plugins/jar/AbstractJarMojo.java  | 25 +++++++++++++---------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
index 058ac05..25558ed 100644
--- a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
@@ -62,26 +62,26 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
      * is being packaged into the JAR.
      */
     @Parameter
-    private String[] includes;
+    protected String[] includes;
 
     /**
      * List of files to exclude. Specified as fileset patterns which are relative to the input directory whose contents
      * is being packaged into the JAR.
      */
     @Parameter
-    private String[] excludes;
+    protected String[] excludes;
 
     /**
      * Directory containing the generated JAR.
      */
     @Parameter(defaultValue = "${project.build.directory}", required = true)
-    private Path outputDirectory;
+    protected Path outputDirectory;
 
     /**
      * Name of the generated JAR.
      */
     @Parameter(defaultValue = "${project.build.finalName}", readonly = true)
-    private String finalName;
+    protected String finalName;
 
     /**
      * The JAR archiver.
@@ -106,7 +106,7 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
      * Archiver Reference</a>.
      */
     @Parameter
-    private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+    protected MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
 
     @Inject
     private ProjectManager projectManager;
@@ -124,13 +124,13 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
      * to {@code maven.jar.forceCreation}.</p>
      */
     @Parameter(property = "maven.jar.forceCreation", defaultValue = "false")
-    private boolean forceCreation;
+    protected boolean forceCreation;
 
     /**
      * Skip creating empty archives.
      */
     @Parameter(defaultValue = "false")
-    private boolean skipIfEmpty;
+    protected boolean skipIfEmpty;
 
     /**
      * Timestamp for reproducible output archive entries.
@@ -142,7 +142,7 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
      * @since 3.2.0
      */
     @Parameter(defaultValue = "${project.build.outputTimestamp}")
-    private String outputTimestamp;
+    protected String outputTimestamp;
 
     /**
      * Whether to detect multi-release JAR files.
@@ -152,7 +152,7 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
      * @since 3.4.0
      */
     @Parameter(property = "maven.jar.detectMultiReleaseJar", defaultValue = "true")
-    private boolean detectMultiReleaseJar;
+    protected boolean detectMultiReleaseJar;
 
     /**
      * The <abbr>MOJO</abbr> logger.
@@ -228,7 +228,12 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
      * @throws MojoException in case of an error
      */
     public Path createArchive() throws MojoException {
-        Path jarFile = getJarFile(outputDirectory, finalName, getClassifier());
+        Path basedir = outputDirectory != null
+                ? outputDirectory
+                : Path.of(project.getBuild().getDirectory());
+        String resultFinalName =
+                finalName != null ? finalName : project.getBuild().getFinalName();
+        Path jarFile = getJarFile(basedir, resultFinalName, getClassifier());
 
         FileSetManager fileSetManager = new FileSetManager();
         FileSet jarContentFileSet = new FileSet();


(maven-jar-plugin) 02/02: MJAR: Increase visibility of @Inject fields to protected to ensure proper injection in Maven 4

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git

commit f631e64ea719dabfea36f6e6730c8763260aabb7
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Jun 13 20:33:49 2026 +0200

    MJAR: Increase visibility of @Inject fields to protected to ensure proper injection in Maven 4
---
 .../org/apache/maven/plugins/jar/AbstractJarMojo.java     | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
index 25558ed..811039c 100644
--- a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
@@ -87,19 +87,19 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
      * The JAR archiver.
      */
     @Inject
-    private Map<String, Archiver> archivers;
+    protected Map<String, Archiver> archivers;
 
     /**
      * The Maven project.
      */
     @Inject
-    private Project project;
+    protected Project project;
 
     /**
      * The session.
      */
     @Inject
-    private Session session;
+    protected Session session;
 
     /**
      * The archive configuration to use. See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven
@@ -109,7 +109,7 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
     protected MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
 
     @Inject
-    private ProjectManager projectManager;
+    protected ProjectManager projectManager;
 
     /**
      * Require the jar plugin to build a new JAR even if none of the contents appear to have changed.
@@ -158,7 +158,7 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
      * The <abbr>MOJO</abbr> logger.
      */
     @Inject
-    private Log log;
+    protected Log log;
 
     /**
      * Creates a new <abbr>MOJO</abbr>.
@@ -304,9 +304,10 @@ public abstract class AbstractJarMojo implements org.apache.maven.api.plugin.Moj
             getLog().info(String.format("Skipping packaging of the %s.", getType()));
         } else {
             Path jarFile = createArchive();
-            ProducedArtifact artifact;
-            String classifier = getClassifier();
+
             if (attach) {
+                ProducedArtifact artifact;
+                String classifier = getClassifier();
                 if (hasClassifier(classifier)) {
                     artifact = session.createProducedArtifact(
                             project.getGroupId(),