This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch fix-mjar-npe
in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git
The following commit(s) were added to refs/heads/fix-mjar-npe by this push:
new 75a1887 MJAR: Increase visibility of @Inject fields to protected to
ensure proper injection in Maven 4
75a1887 is described below
commit 75a1887969949a203d2b3df34d2b7dc95f150a93
Author: Sylwester Lachiewicz <[email protected]>
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(),