Author: olamy
Date: Mon Feb  4 14:31:24 2013
New Revision: 1442131

URL: http://svn.apache.org/viewvc?rev=1442131&view=rev
Log:
[MDEP-301] Allow build-classpath to output to property
Submitted by Ryan Heinen.

Modified:
    
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java
    
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java
    
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DependencyProjectStub.java

Modified: 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java?rev=1442131&r1=1442130&r2=1442131&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java
 Mon Feb  4 14:31:24 2013
@@ -85,6 +85,12 @@ public class BuildClasspathMojo
     private File cpFile;
 
     /**
+     * A property to set to the contents of the classpath string.
+     */
+    @Parameter( property = "mdep.outputProperty")
+    private String outputProperty;
+    
+    /**
      * The file to write the classpath string. If undefined, it just prints 
the classpath as [INFO].
      */
     @Parameter( property = "mdep.outputFile" )
@@ -228,7 +234,15 @@ public class BuildClasspathMojo
             cpString = "classpath=" + cpString;
         }
 
-        if ( outputFile == null )
+        if ( outputProperty != null )
+        {
+            project.getProperties().setProperty( outputProperty, cpString );
+            if (getLog().isDebugEnabled())
+            {
+                getLog().debug( outputProperty + " = " + cpString );
+            }
+        }
+        else if ( outputFile == null )
         {
             getLog().info( "Dependencies classpath:\n" + cpString );
         }
@@ -430,6 +444,22 @@ public class BuildClasspathMojo
     }
 
     /**
+     * @return the outputProperty
+     */
+    public String getOutputProperty()
+    {
+        return this.outputProperty;
+    }
+
+    /**
+     * @param theOutputProperty the outputProperty to set
+     */
+    public void setOutputProperty( String theOutputProperty )
+    {
+        this.outputProperty = theOutputProperty;
+    }
+       
+    /**
      * @return the fileSeparator
      */
     public String getFileSeparator()

Modified: 
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java?rev=1442131&r1=1442130&r2=1442131&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestBuildClasspathMojo.java
 Mon Feb  4 14:31:24 2013
@@ -100,6 +100,14 @@ public class TestBuildClasspathMojo
         assertFalse( file.indexOf( File.separator ) >= 0 );
         assertTrue( file.indexOf( fileSep ) >= 0 );
         assertTrue( file.indexOf( pathSep ) >= 0 );
+
+        String propertyValue = project.getProperties().getProperty( 
"outputProperty" );
+        assertNull( propertyValue );
+        mojo.setOutputProperty( "outputProperty" );
+        mojo.execute();
+        propertyValue = project.getProperties().getProperty( "outputProperty" 
);
+        assertNotNull( propertyValue );
+
     }
 
     public void testPath() throws Exception

Modified: 
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DependencyProjectStub.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DependencyProjectStub.java?rev=1442131&r1=1442130&r2=1442131&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DependencyProjectStub.java
 (original)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/DependencyProjectStub.java
 Mon Feb  4 14:31:24 2013
@@ -157,6 +157,8 @@ public class DependencyProjectStub
     private String defaultGoal;
 
     private Set artifacts;
+    
+    private Properties properties;
 
     public DependencyProjectStub()
     {
@@ -1010,7 +1012,10 @@ public class DependencyProjectStub
 
     public Properties getProperties()
     {
-        return new Properties();
+        if (properties == null) {
+            properties = new Properties();
+        }
+        return properties;
     }
 
     public List getFilters()


Reply via email to