You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2018/09/10 18:43:07 UTC

[maven-jlink-plugin] branch MJLINK-26 updated: fixup! fixup! ** WIP - [MJLINK-26] - Can not create an image from a single module project without a dependency

This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MJLINK-26
in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git


The following commit(s) were added to refs/heads/MJLINK-26 by this push:
     new 63d5291  fixup! fixup! ** WIP - [MJLINK-26] - Can not create an image from a single module project without a dependency
63d5291 is described below

commit 63d52910df971cad968213a7d4c916e05bac2ace
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Mon Sep 10 20:43:04 2018 +0200

    fixup! fixup! ** WIP - [MJLINK-26] - Can not create an image from a single module project without a dependency
---
 .../org/apache/maven/plugins/jlink/JLinkMojo.java  | 25 +++++++++++++---------
 1 file changed, 15 insertions(+), 10 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 6af097b..7c06023 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
@@ -354,22 +354,22 @@ public class JLinkMojo
 
             for ( Map.Entry<File, JavaModuleDescriptor> entry : resolvePathsResult.getPathElements().entrySet() )
             {
-                if ( entry.getValue() != null )
-                {
-                    // Don't warn for automatic modules, let the jlink tool do that
-                    modulepathElements.put( entry.getValue().name(), entry.getKey() );
-                }
-                else
+                if ( entry.getValue() == null )
                 {
                     String message = "The given dependency " + entry.getKey()
                         + " does not have a module-info.java file. So it can't be linked.";
                     getLog().error( message );
                     throw new MojoFailureException( message );
                 }
+
+                // Don't warn for automatic modules, let the jlink tool do that
+                getLog().debug( " module: " + entry.getValue().name() + " automatic: "
+                    + entry.getValue().isAutomatic() );
+                modulepathElements.put( entry.getValue().name(), entry.getKey() );
             }
-            
 
             // This part is for the module in target/classes ? (Hacky..)
+            // FIXME: Is there a better way to identify ?
             if ( outputDirectory.exists() )
             {
                 List<File> singletonList = Collections.singletonList( outputDirectory );
@@ -379,17 +379,22 @@ public class JLinkMojo
                 ResolvePathsResult<File> resolvePaths = locationManager.resolvePaths( singleModuls );
                 for ( Entry<File, JavaModuleDescriptor> entry : resolvePaths.getPathElements().entrySet() )
                 {
-                    if ( entry.getValue() != null )
+                    if ( entry.getValue() == null )
                     {
-                        modulepathElements.put( entry.getValue().name(), entry.getKey() );
+                        String message = "The given project " + entry.getKey()
+                            + " does not contain a module-info.java file. So it can't be linked.";
+                        getLog().error( message );
+                        throw new MojoFailureException( message );
                     }
+                    modulepathElements.put( entry.getValue().name(), entry.getKey() );
                 }
             }
 
         }
         catch ( IOException e )
         {
-            getLog().warn( e.getMessage() );
+            getLog().error( e.getMessage() );
+            throw new MojoFailureException( e.getMessage() );
         }
 
         return modulepathElements;