@@ -474,17 +474,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
474474
475475 File createZipArchiveFromImage = createZipArchiveFromImage (buildDirectory , outputDirectoryImage );
476476
477- if (attach ) {
478- if (hasClassifier ()) {
479- projectHelper .attachArtifact (getProject (), "jlink" , getClassifier (), createZipArchiveFromImage );
480- } else {
481- if (projectHasAlreadySetAnArtifact ()) {
482- throw new MojoExecutionException ("You have to use a classifier "
483- + "to attach supplemental artifacts to the project instead of replacing them." );
484- }
485- getProject ().getArtifact ().setFile (createZipArchiveFromImage );
486- }
487- }
477+ attachArtifactUnlessDisabled (createZipArchiveFromImage );
488478 }
489479
490480 /**
@@ -640,6 +630,22 @@ private File createZipArchiveFromImage(File outputDirectory, File outputDirector
640630 return resultArchive ;
641631 }
642632
633+ private void attachArtifactUnlessDisabled (File artifactFile ) throws MojoExecutionException {
634+ if (!attach ) {
635+ return ;
636+ }
637+
638+ if (hasClassifier ()) {
639+ projectHelper .attachArtifact (getProject (), "jlink" , getClassifier (), artifactFile );
640+ } else {
641+ if (projectHasAlreadySetAnArtifact ()) {
642+ throw new MojoExecutionException ("You have to use a classifier "
643+ + "to attach supplemental artifacts to the project instead of replacing them." );
644+ }
645+ getProject ().getArtifact ().setFile (artifactFile );
646+ }
647+ }
648+
643649 private void failIfParametersAreNotInTheirValidValueRanges () throws MojoFailureException {
644650 if (endian != null && (!"big" .equals (endian ) && !"little" .equals (endian ))) {
645651 String message = "The given endian parameter " + endian
0 commit comments