You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by pg...@apache.org on 2010/01/28 20:20:42 UTC

svn commit: r904219 - in /maven/plugins/trunk/maven-antrun-plugin/src: it/properties-test/ main/java/org/apache/maven/plugin/antrun/ site/apt/examples/

Author: pgier
Date: Thu Jan 28 19:20:41 2010
New Revision: 904219

URL: http://svn.apache.org/viewvc?rev=904219&view=rev
Log:
[MANTRUN-126] Change format of dependency property names.

Modified:
    maven/plugins/trunk/maven-antrun-plugin/src/it/properties-test/build.xml
    maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
    maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntPropertyHelper.java
    maven/plugins/trunk/maven-antrun-plugin/src/site/apt/examples/classpaths.apt.vm

Modified: maven/plugins/trunk/maven-antrun-plugin/src/it/properties-test/build.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/it/properties-test/build.xml?rev=904219&r1=904218&r2=904219&view=diff
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/it/properties-test/build.xml (original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/it/properties-test/build.xml Thu Jan 28 19:20:41 2010
@@ -1,13 +1,19 @@
 <?xml version="1.0"?>
 <project name="properties-test">
 
-    <target name="test">
+  <target name="test">
 
-        <fail unless="maven.project.artifactId" message="Property not set ${maven.project.artifactId}"/>
-        <fail unless="testProp1" message="Property not set ${testProp1}"/>
-        <fail unless="maven.dependency.junit.junit.jar.path" message="Property not set ${maven.dependency.junit.junit.jar.path}"/>
-        <fail unless="line.separator" message="Property not set ${line.separator}"/>
+    <echo message="project.artifactId : ${project.artifactId}"/>
+    <fail unless="project.artifactId" message="Property not set \${project.artifactId}"/>
+    <echo message="testProp1 : ${testProp1}"/>
+    <fail unless="testProp1" message="Property not set \${testProp1}"/>
+    <echo message="line.separator : ${line.separator}"/>
+    <fail unless="line.separator" message="Property not set \${line.separator}"/>
+    <echo message="junit:junit:jar : ${junit:junit:jar}"/>
+    <fail unless="junit:junit:jar" message="Property not set \${junit:junit:jar}"/>    
+    <echo message="maven.dependency.junit.junit.jar.path : ${maven.dependency.junit.junit.jar.path}"/>
+    <fail unless="maven.dependency.junit.junit.jar.path" message="Property not set \${maven.dependency.junit.junit.jar.path}"/>
       
-    </target>
+  </target>
 
 </project>

Modified: maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java?rev=904219&r1=904218&r2=904219&view=diff
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java (original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AbstractAntMojo.java Thu Jan 28 19:20:41 2010
@@ -53,6 +53,12 @@
     extends AbstractMojo
 {
     /**
+     * String to prepend to project and dependency property names.
+     * @parameter default-value=""
+     */
+    private String propertyPrefix;
+    
+    /**
      * @deprecated use {@link AbstractAntMojo#executeTasks(Target,MavenProject,List)}.
      */
     protected void executeTasks( Target antTasks, MavenProject mavenProject )
@@ -74,6 +80,11 @@
             getLog().info( "No ant tasks defined - SKIPPED" );
             return;
         }
+        
+        if ( propertyPrefix == null )
+        {
+            propertyPrefix = "";
+        }
 
         try
         {
@@ -192,27 +203,38 @@
         antProject.setProperty( "ant.file", mavenProject.getFile().getAbsolutePath() );
         
         // Add some of the common maven properties
-        antProject.setProperty( "maven.project.groupId", mavenProject.getGroupId() );
-        antProject.setProperty( "maven.project.artifactId", mavenProject.getArtifactId() );
-        antProject.setProperty( "maven.project.name", mavenProject.getName() );
-        antProject.setProperty( "maven.project.description", mavenProject.getDescription() );
-        antProject.setProperty( "maven.project.version", mavenProject.getVersion() );
-        antProject.setProperty( "maven.project.packaging", mavenProject.getPackaging() );
-        antProject.setProperty( "maven.project.build.directory", mavenProject.getBuild().getDirectory() );
-        antProject.setProperty( "maven.project.build.outputDirectory", mavenProject.getBuild().getOutputDirectory() );
-        antProject.setProperty( "maven.project.build.outputDirectory", mavenProject.getBuild().getTestOutputDirectory() );
-        antProject.setProperty( "maven.project.build.sourceDirectory", mavenProject.getBuild().getSourceDirectory() );
-        antProject.setProperty( "maven.project.build.testSourceDirectory", mavenProject.getBuild().getTestSourceDirectory() );
+        System.out.println( (propertyPrefix+ "project.artifactId"));
+        antProject.setProperty( ( propertyPrefix + "project.groupId" ), mavenProject.getGroupId() );
+        antProject.setProperty( ( propertyPrefix + "project.artifactId" ), mavenProject.getArtifactId() );
+        antProject.setProperty( ( propertyPrefix + "project.name" ), mavenProject.getName() );
+        antProject.setProperty( ( propertyPrefix + "project.description" ), mavenProject.getDescription() );
+        antProject.setProperty( ( propertyPrefix + "project.version" ), mavenProject.getVersion() );
+        antProject.setProperty( ( propertyPrefix + "project.packaging" ), mavenProject.getPackaging() );
+        antProject.setProperty( ( propertyPrefix + "project.build.directory" ), mavenProject.getBuild().getDirectory() );
+        antProject.setProperty( ( propertyPrefix + "project.build.outputDirectory" ), mavenProject.getBuild().getOutputDirectory() );
+        antProject.setProperty( ( propertyPrefix + "project.build.outputDirectory" ), mavenProject.getBuild().getTestOutputDirectory() );
+        antProject.setProperty( ( propertyPrefix + "project.build.sourceDirectory" ), mavenProject.getBuild().getSourceDirectory() );
+        antProject.setProperty( ( propertyPrefix + "project.build.testSourceDirectory" ), mavenProject.getBuild().getTestSourceDirectory() );
+        
+        // Add properties for depenedency artifacts
+        Set depArtifacts = mavenProject.getDependencyArtifacts();
+        for ( Iterator it = depArtifacts.iterator(); it.hasNext(); )
+        {
+            Artifact artifact = (Artifact) it.next();
+
+            String propName = artifact.getDependencyConflictId();
+
+            antProject.setProperty( propertyPrefix + propName, artifact.getFile().getPath() );
+        }
         
-        // Add paths to depenedency artifacts
-        Set artifacts = mavenProject.getDependencyArtifacts();
-        for ( Iterator it = artifacts.iterator(); it.hasNext(); )
+        // Add properties in deprecated format to depenedency artifacts
+        for ( Iterator it = depArtifacts.iterator(); it.hasNext(); )
         {
             Artifact artifact = (Artifact) it.next();
 
-            String key = AntPropertyHelper.getDependencyArtifactPropertyName( artifact );
+            String propName = AntPropertyHelper.getDependencyArtifactPropertyName( artifact );
 
-            antProject.setProperty( key, artifact.getFile().getPath() );
+            antProject.setProperty( propName, artifact.getFile().getPath() );
         }
     }
 }

Modified: maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntPropertyHelper.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntPropertyHelper.java?rev=904219&r1=904218&r2=904219&view=diff
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntPropertyHelper.java (original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntPropertyHelper.java Thu Jan 28 19:20:41 2010
@@ -97,7 +97,8 @@
      * maven.dependency.groupId.artifactId[.classifier].type.path
      * 
      * @param artifact
-     * @return
+     * @return property name
+     * @deprecated The dependency conflict ID should be used as the property name.
      */
     public static String getDependencyArtifactPropertyName( Artifact artifact )
     {

Modified: maven/plugins/trunk/maven-antrun-plugin/src/site/apt/examples/classpaths.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/site/apt/examples/classpaths.apt.vm?rev=904219&r1=904218&r2=904219&view=diff
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/site/apt/examples/classpaths.apt.vm (original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/site/apt/examples/classpaths.apt.vm Thu Jan 28 19:20:41 2010
@@ -29,11 +29,11 @@
 Referencing the Maven Classpaths
 
  A property is set for each dependency with the format 
- "maven.dependency.groupId.artifactId[.classifier].type.path".  For example, to show the path
+ "groupId:artifactId[:classifier]:type".  For example, to show the path
  to a dependency with groupId "org.apache" and artifactId "common-util", the following could be used.
 
 ------
-<echo message="My Dependency JAR Path: ${mvn.dependency.org.apache.common-util.jar.path}"/> 
+<echo message="Dependency JAR Path: ${org.apache:common-util:jar}"/> 
 ------
  
  You can also use these classpath references: