@@ -334,6 +334,14 @@ public class JLinkMojo extends AbstractJLinkMojo {
334334 @ Parameter
335335 private File sourceJdkModules ;
336336
337+ /**
338+ * Controls whether the plugin tries to attach the resulting artifact to the project.
339+ *
340+ * @since 3.2.1
341+ */
342+ @ Parameter (defaultValue = "true" )
343+ private boolean attach ;
344+
337345 /**
338346 * Classifier to add to the artifact generated. If given, the artifact will be attached
339347 * as a supplemental artifact.
@@ -453,14 +461,16 @@ public void execute() throws MojoExecutionException, MojoFailureException {
453461
454462 File createZipArchiveFromImage = createZipArchiveFromImage (buildDirectory , outputDirectoryImage );
455463
456- if (hasClassifier ()) {
457- projectHelper .attachArtifact (getProject (), "jlink" , getClassifier (), createZipArchiveFromImage );
458- } else {
459- if (projectHasAlreadySetAnArtifact ()) {
460- throw new MojoExecutionException ("You have to use a classifier "
461- + "to attach supplemental artifacts to the project instead of replacing them." );
464+ if (attach ) {
465+ if (hasClassifier ()) {
466+ projectHelper .attachArtifact (getProject (), "jlink" , getClassifier (), createZipArchiveFromImage );
467+ } else {
468+ if (projectHasAlreadySetAnArtifact ()) {
469+ throw new MojoExecutionException ("You have to use a classifier "
470+ + "to attach supplemental artifacts to the project instead of replacing them." );
471+ }
472+ getProject ().getArtifact ().setFile (createZipArchiveFromImage );
462473 }
463- getProject ().getArtifact ().setFile (createZipArchiveFromImage );
464474 }
465475 }
466476
0 commit comments