You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/08/08 13:46:30 UTC

svn commit: r983388 - /maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java

Author: bentmann
Date: Sun Aug  8 11:46:29 2010
New Revision: 983388

URL: http://svn.apache.org/viewvc?rev=983388&view=rev
Log:
o Extended IT plugin to enable external validation

Modified:
    maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java

Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java?rev=983388&r1=983387&r2=983388&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-artifact/src/main/java/org/apache/maven/plugin/coreit/ResolveMojo.java Sun Aug  8 11:46:29 2010
@@ -28,7 +28,12 @@ import org.apache.maven.plugin.AbstractM
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.List;
+import java.util.Properties;
 
 /**
  * Resolves user-specified artifacts. This mimics in part the Maven Dependency Plugin and the Maven Surefire Plugin.
@@ -82,6 +87,13 @@ public class ResolveMojo
     private Dependency[] dependencies;
 
     /**
+     * The path to a properties file to store the resolved artifact paths in.
+     * 
+     * @parameter
+     */
+    private File propertiesFile;
+
+    /**
      * Runs this mojo.
      * 
      * @throws MojoFailureException If the artifact file has not been set.
@@ -91,6 +103,8 @@ public class ResolveMojo
     {
         getLog().info( "[MAVEN-CORE-IT-LOG] Resolving artifacts" );
 
+        Properties props = new Properties();
+
         try
         {
             if ( dependencies != null )
@@ -104,10 +118,15 @@ public class ResolveMojo
                                                               dependency.getVersion(), dependency.getType(),
                                                               dependency.getClassifier() );
 
-                    getLog().info( "[MAVEN-CORE-IT-LOG] Resolving " + artifact.getId() );
+                    getLog().info( "[MAVEN-CORE-IT-LOG] Resolving " + getId( artifact ) );
 
                     resolver.resolve( artifact, remoteRepositories, localRepository );
 
+                    if ( artifact.getFile() != null )
+                    {
+                        props.setProperty( getId( artifact ), artifact.getFile().getPath() );
+                    }
+
                     getLog().info( "[MAVEN-CORE-IT-LOG]   " + artifact.getFile() );
                 }
             }
@@ -116,6 +135,35 @@ public class ResolveMojo
         {
             throw new MojoExecutionException( "Failed to resolve artifacts: " + e.getMessage(), e );
         }
+
+        if ( propertiesFile != null )
+        {
+            getLog().info( "[MAVEN-CORE-IT-LOG] Creating properties file " + propertiesFile );
+
+            try
+            {
+                propertiesFile.getParentFile().mkdirs();
+
+                FileOutputStream fos = new FileOutputStream( propertiesFile );
+                try
+                {
+                    props.store( fos, "MAVEN-CORE-IT" );
+                }
+                finally
+                {
+                    fos.close();
+                }
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Failed to create properties file: " + e.getMessage(), e );
+            }
+        }
+    }
+
+    private String getId( Artifact artifact )
+    {
+        return artifact.getId();
     }
 
 }