bmarwell commented on a change in pull request #21:
URL: https://github.com/apache/maven-jlink-plugin/pull/21#discussion_r531052492



##########
File path: src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
##########
@@ -428,11 +437,13 @@ private JLinkExecutor getExecutor()
         return getJlinkExecutor();
     }
 
-    private boolean projectHasAlreadySetAnArtifact()
+    private boolean projectHasAlreadySetAnArtifact( File 
createZipArchiveFromImage )
     {
-        if ( getProject().getArtifact().getFile() != null )
+        Optional<File> file = Optional.ofNullable( 
getProject().getArtifact().getFile() );
+        if ( file.isPresent() )
         {
-            return getProject().getArtifact().getFile().isFile();
+            File projectArtifact = file.orElseThrow( 
NoSuchElementException::new );
+            return projectArtifact.getName().equals( 
createZipArchiveFromImage.getName() );

Review comment:
       I believe someone used a shortcut here and we need to iterate and check 
all of `getProject().getAttachedArtifacts()`.
   As I have never coded for classifier support, please take a look at these 
lines.
   
   `getArtifact()` sounds like the primary artifact. But the 
`maven-jlink-plugin` could also attach a zip file to a `packaging=jar` project 
as a secondary artifact, could it not?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to