@@ -334,6 +334,12 @@ 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+ @ Parameter (defaultValue = "true" )
341+ private boolean attach ;
342+
337343 /**
338344 * Classifier to add to the artifact generated. If given, the artifact will be attached
339345 * as a supplemental artifact.
@@ -453,14 +459,16 @@ public void execute() throws MojoExecutionException, MojoFailureException {
453459
454460 File createZipArchiveFromImage = createZipArchiveFromImage (buildDirectory , outputDirectoryImage );
455461
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." );
462+ if (attach ) {
463+ if (hasClassifier ()) {
464+ projectHelper .attachArtifact (getProject (), "jlink" , getClassifier (), createZipArchiveFromImage );
465+ } else {
466+ if (projectHasAlreadySetAnArtifact ()) {
467+ throw new MojoExecutionException ("You have to use a classifier "
468+ + "to attach supplemental artifacts to the project instead of replacing them." );
469+ }
470+ getProject ().getArtifact ().setFile (createZipArchiveFromImage );
462471 }
463- getProject ().getArtifact ().setFile (createZipArchiveFromImage );
464472 }
465473 }
466474
0 commit comments