This is an automated email from the ASF dual-hosted git repository. bmarwell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git
commit d6c696ed15d4f49d3a9aa6eb89724ba81dcfe0f4 Author: Peter <[email protected]> AuthorDate: Sat Jul 19 18:31:49 2025 +1000 Add support for optional attach parameter to disable artifact attachment --- .../org/apache/maven/plugins/jlink/JLinkMojo.java | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java index 5a5c3a7..4fdabc5 100644 --- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java +++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java @@ -334,6 +334,14 @@ public class JLinkMojo extends AbstractJLinkMojo { @Parameter private File sourceJdkModules; + /** + * Controls whether the plugin tries to attach the resulting artifact to the project. + * + * @since 3.2.1 + */ + @Parameter(defaultValue = "true") + private boolean attach; + /** * Classifier to add to the artifact generated. If given, the artifact will be attached * as a supplemental artifact. @@ -466,14 +474,16 @@ public class JLinkMojo extends AbstractJLinkMojo { File createZipArchiveFromImage = createZipArchiveFromImage(buildDirectory, outputDirectoryImage); - if (hasClassifier()) { - projectHelper.attachArtifact(getProject(), "jlink", getClassifier(), createZipArchiveFromImage); - } else { - if (projectHasAlreadySetAnArtifact()) { - throw new MojoExecutionException("You have to use a classifier " - + "to attach supplemental artifacts to the project instead of replacing them."); + if (attach) { + if (hasClassifier()) { + projectHelper.attachArtifact(getProject(), "jlink", getClassifier(), createZipArchiveFromImage); + } else { + if (projectHasAlreadySetAnArtifact()) { + throw new MojoExecutionException("You have to use a classifier " + + "to attach supplemental artifacts to the project instead of replacing them."); + } + getProject().getArtifact().setFile(createZipArchiveFromImage); } - getProject().getArtifact().setFile(createZipArchiveFromImage); } }
