Author: khmarbaise
Date: Mon Jun 26 17:43:43 2017
New Revision: 1799963

URL: http://svn.apache.org/viewvc?rev=1799963&view=rev
Log:
Added result image as archive to the project so
an mvn install/deploy now works.

Modified:
    
maven/plugins/trunk/maven-jlink-plugin/src/main/filtered-resources/META-INF/plexus/components.xml
    
maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
    
maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java

Modified: 
maven/plugins/trunk/maven-jlink-plugin/src/main/filtered-resources/META-INF/plexus/components.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jlink-plugin/src/main/filtered-resources/META-INF/plexus/components.xml?rev=1799963&r1=1799962&r2=1799963&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-jlink-plugin/src/main/filtered-resources/META-INF/plexus/components.xml
 (original)
+++ 
maven/plugins/trunk/maven-jlink-plugin/src/main/filtered-resources/META-INF/plexus/components.xml
 Mon Jun 26 17:43:43 2017
@@ -31,7 +31,6 @@
       <configuration>
         <type>jlink</type>
         <extension>zip</extension>
-        <!-- Need to check the following? -->
         <includesDependencies>true</includesDependencies>
         <language>java</language>
         <addedToClasspath>false</addedToClasspath>
@@ -59,8 +58,6 @@
               <package>
                 
org.apache.maven.plugins:maven-jlink-plugin:${project.version}:jlink
               </package>
-              <!-- What should be installed?
-              JRE image in zip/tar format? -->
               <install>
                 org.apache.maven.plugins:maven-install-plugin:2.5.2:install
               </install>

Modified: 
maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java?rev=1799963&r1=1799962&r2=1799963&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkMojo.java
 Mon Jun 26 17:43:43 2017
@@ -251,6 +251,7 @@ public abstract class AbstractJLinkMojo
 
         if ( tc == null )
         {
+            // TODO: Check if we should make the type configurable?
             tc = toolchainManager.getToolchainFromBuildContext( "jdk", session 
);
         }
 

Modified: 
maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java?rev=1799963&r1=1799962&r2=1799963&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-jlink-plugin/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
 Mon Jun 26 17:43:43 2017
@@ -204,7 +204,7 @@ public class JLinkMojo
     private ArchiverManager manager;
 
     /**
-     * The kind of archive we should produce.
+     * The kind of archive we will produce.
      */
     @Parameter( defaultValue = "zip", required = true )
     private String archiveType;
@@ -246,7 +246,7 @@ public class JLinkMojo
 
         failIfParametersAreNotInTheirValidValueRanges();
 
-        deleteOutputDirectoryIfItAlreadyExists();
+        ifOutputDirectoryExistsDelteIt();
 
         List<Dependency> dependencies = 
getSession().getCurrentProject().getDependencies();
 
@@ -284,13 +284,25 @@ public class JLinkMojo
 
         File createZipArchiveFromImage = createZipArchiveFromImage( 
outputDirectory, outputDirectoryImage );
 
-        // Set main artifact.
+        if ( projectHasAlreadySetAnArtifact() )
+        {
+            throw new MojoExecutionException( "You have to use a classifier "
+                + "to attach supplemental artifacts to the project instead of 
replacing them." );
+        }
+
         getProject().getArtifact().setFile( createZipArchiveFromImage );
-        // artifact.setFile( createZipArchiveFromImage );
-        // getProject().setFile( createZipArchiveFromImage );
-        // packaging is something different than type..
-        // projectHelper.attachArtifact( getProject(), "image", "image", 
createZipArchiveFromImage );
+    }
 
+    private boolean projectHasAlreadySetAnArtifact()
+    {
+        if ( getProject().getArtifact().getFile() != null )
+        {
+            return getProject().getArtifact().getFile().isFile();
+        }
+        else
+        {
+            return false;
+        }
     }
 
     private File createZipArchiveFromImage( File outputDirectory, File 
outputDirectoryImage )
@@ -396,7 +408,7 @@ public class JLinkMojo
         // }
     }
 
-    private void deleteOutputDirectoryIfItAlreadyExists()
+    private void ifOutputDirectoryExistsDelteIt()
         throws MojoExecutionException
     {
         if ( outputDirectoryImage.exists() )


Reply via email to