You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2010/02/28 10:41:06 UTC
svn commit: r917149 - in /maven/ant-tasks/trunk: ./
src/it/ant-run-plugin-with-ant-1.8.0/
src/main/java/org/apache/maven/artifact/ant/
Author: hboutemy
Date: Sun Feb 28 09:41:06 2010
New Revision: 917149
URL: http://svn.apache.org/viewvc?rev=917149&view=rev
Log:
[MANTTASKS-178] fixed pom properties resolution to be compatible with both Ant 1.6 to 1.7.1 property intercepter API and the new Ant 1.8.0 property delegate API
Added:
maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/
maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/build.xml (with props)
maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/pom.xml (with props)
maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/verify.bsh (with props)
Modified:
maven/ant-tasks/trunk/pom.xml
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java
Modified: maven/ant-tasks/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/pom.xml?rev=917149&r1=917148&r2=917149&view=diff
==============================================================================
--- maven/ant-tasks/trunk/pom.xml (original)
+++ maven/ant-tasks/trunk/pom.xml Sun Feb 28 09:41:06 2010
@@ -114,12 +114,12 @@
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/ant-tasks/trunk</developerConnection>
<url>http://svn.apache.org/viewvc/maven/ant-tasks/trunk</url>
</scm>
-
+
<issueManagement>
<system>jira</system>
<url>http://jira.codehaus.org/browse/MANTTASKS</url>
</issueManagement>
-
+
<distributionManagement>
<site>
<id>apache.website</id>
@@ -134,9 +134,9 @@
<dependencies>
<dependency>
- <groupId>ant</groupId>
+ <groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
- <version>1.6.5</version>
+ <version>1.8.0</version>
</dependency>
<dependency>
<groupId>classworlds</groupId>
@@ -331,5 +331,5 @@
</build>
</profile>
</profiles>
-
+
</project>
Added: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/build.xml
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/build.xml?rev=917149&view=auto
==============================================================================
--- maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/build.xml (added)
+++ maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/build.xml Sun Feb 28 09:41:06 2010
@@ -0,0 +1,25 @@
+<project name="maven-ant-tasks" default="test" xmlns:artifact="urn:maven-artifact-ant" xmlns:test="urn:test-tasks">
+
+ <target name="initTaskDefs">
+ <xmlproperty file="../../../pom.xml" prefix="pom.xml" />
+
+ <path id="maven-ant-tasks.classpath" path="../../maven-ant-tasks-${pom.xml.project.version}.jar" />
+ <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
+ classpathref="maven-ant-tasks.classpath"/>
+ </target>
+
+
+ <target name="test" depends="initTaskDefs">
+ <artifact:localRepository id="local.repository" path="${basedir}/target/local-repo" layout="default"/>
+
+ <artifact:pom file="pom.xml" id="mypom"/>
+ <mkdir dir="target"/>
+ <touch file="target/${mypom.build.finalName}"/>
+
+ <artifact:dependencies fileSetId="mydeps" pomRefId="mypom"/>
+ <copy todir="target">
+ <fileset refid="mydeps"/>
+ </copy>
+ </target>
+
+</project>
\ No newline at end of file
Propchange: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/build.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/pom.xml
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/pom.xml?rev=917149&view=auto
==============================================================================
--- maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/pom.xml (added)
+++ maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/pom.xml Sun Feb 28 09:41:06 2010
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>it.ant-tasks</groupId>
+ <artifactId>ant-run</artifactId>
+ <packaging>pom</packaging>
+
+ <name>ant-run</name>
+ <version>0.10-SNAPSHOT</version>
+ <description>
+ Try to call the ant tasks through the ant run plugin.
+ </description>
+
+ <build>
+ <finalName>testfile</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.8.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>run</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <tasks>
+ <ant antfile="build.xml"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/verify.bsh
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/verify.bsh?rev=917149&view=auto
==============================================================================
--- maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/verify.bsh (added)
+++ maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/verify.bsh Sun Feb 28 09:41:06 2010
@@ -0,0 +1,30 @@
+import java.io.*;
+import java.util.*;
+import org.codehaus.plexus.util.*;
+
+try
+{
+ File outputFolder = new File( basedir, "target/" );
+
+ File testFile = new File( outputFolder, "testfile");
+ if ( !testFile.isFile() )
+ {
+ System.err.println( "Could not find generated file: " + testFile );
+ return false;
+ }
+
+ File depFile = new File( outputFolder, "org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.jar");
+ if ( !depFile.isFile() )
+ {
+ System.err.println( "Could not find copied dependency file: " + depFile );
+ return false;
+ }
+
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Propchange: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/verify.bsh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/ant-tasks/trunk/src/it/ant-run-plugin-with-ant-1.8.0/verify.bsh
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java?rev=917149&r1=917148&r2=917149&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java Sun Feb 28 09:41:06 2010
@@ -59,7 +59,7 @@
* A POM typedef. Also an Ant Task that registers a handler called POMPropertyHelper that intercepts all calls to
* property value resolution and replies instead of Ant to properties that start with the id of the pom. Example:
* ${maven.project.artifactId}
- *
+ *
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a>
* @version $Id$
@@ -106,7 +106,7 @@
/**
* The ID used to retrieve this pom object from the Ant project.
- *
+ *
* @param refid
*/
public void setRefid( String refid )
@@ -116,7 +116,7 @@
/**
* The ID used to store this pom object in the Ant project.
- *
+ *
* @param id
*/
public void setId( String id )
@@ -126,7 +126,7 @@
/**
* Retrieve the pom object from the current Ant project using the configured refid.
- *
+ *
* @param refid
* @return
*/
@@ -357,7 +357,7 @@
}
/**
- * Registers POMPropertyHelper as a property interceptor
+ * Registers POMPropertyHelper as a property interceptor in Ant 1.6 - 1.7.1, or property delegate in Ant 1.8.0
*/
protected void doExecute()
{
@@ -374,21 +374,30 @@
// Add a reference to this task/type
antProject.addReference( antId, this );
- // Register the property intercepter
+ // Register the property intercepter or delegate
PropertyHelper phelper = PropertyHelper.getPropertyHelper( antProject );
- helper.setNext( phelper.getNext() );
- helper.setProject( antProject );
- phelper.setNext( helper );
+ try
+ {
+ // Ant 1.8.0 delegate
+ phelper.add( new POMPropertyEvaluator() );
+ }
+ catch ( NoSuchMethodError nsme )
+ {
+ // fallback to 1.6 - 1.7.1 intercepter chaining
+ helper.setNext( phelper.getNext() );
+ helper.setProject( antProject );
+ phelper.setNext( helper );
+ }
}
/**
- * The property intercepter that handles the calls for "pom." properties
+ * The property intercepter that handles the calls for "pom." properties in Ant 1.6 - 1.7.1
*/
private class POMPropertyHelper
extends PropertyHelper
{
/**
- * The method that gets called by Ant with every request of property
+ * The method that gets called by Ant 1.6 - 1.7.1 with every request of property
*/
public Object getPropertyHook( String ns, String name, boolean user )
{
@@ -414,7 +423,7 @@
private static final String PROPERTIES_PREFIX = "project.properties.";
- private Object getPOMValue( String expression )
+ protected Object getPOMValue( String expression )
{
Object value = null;
@@ -441,6 +450,37 @@
}
/**
+ * POM Property Delegate, for Ant 1.8.0.
+ *
+ * @since maven-ant-tasks 2.1.1
+ */
+ private class POMPropertyEvaluator
+ extends POMPropertyHelper
+ implements PropertyHelper.PropertyEvaluator
+ {
+ public Object evaluate(String property, PropertyHelper propertyHelper) {
+ String prefix = antId + ".";
+
+ if ( !property.startsWith( prefix ) )
+ {
+ return null;
+ }
+
+ try
+ {
+ // else handle the property resolution
+ String expression = property.substring( prefix.length() );
+ return getPOMValue( "project." + expression );
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+ }
+
+ /**
* The repositories defined in the ant "pom" task need to be added manually to the profile manager. Otherwise they
* won't be available when resolving the parent pom. MANTTASKS-87
*/
@@ -498,7 +538,7 @@
/**
* Create a project builder configuration to be used when initializing the maven project.
- *
+ *
* @return
*/
private ProjectBuilderConfiguration createProjectBuilderConfig( ArtifactRepository localArtifactRepository )
@@ -514,7 +554,7 @@
/**
* Convert the Hashtable of Ant project properties to a Properties object
- *
+ *
* @return The Ant project properties
*/
public Properties getAntProjectProperties()
@@ -544,7 +584,7 @@
/**
* If set to true, all properties are passed to the maven pom. If set to false, only user properties are passed to
* the pom.
- *
+ *
* @param inheritAllProperties
*/
public void setInheritAllProperties( boolean inheritAllProperties )
@@ -616,12 +656,12 @@
{
getMavenProject().setIssueManagement( issueManagement );
}
-
+
public void addConfiguredLicense ( License license )
{
getMavenProject().addLicense( license );
}
-
+
public void addConfiguredMailingLists( MailingList mailingList )
{
getMavenProject().addMailingList( mailingList );
Re: svn commit: r917149 - in /maven/ant-tasks/trunk: ./ src/it/ant-run-plugin-with-ant-1.8.0/ src/main/java/org/apache/maven/artifact/ant/
Posted by Hervé BOUTEMY <he...@free.fr>.
np, glad to be able to help Maven 3 happen.
Thank you for your code enhancements, and your overall work
Hervé
Le dimanche 28 février 2010, Benjamin Bentmann a écrit :
> > Author: hboutemy
> > Date: Sun Feb 28 09:41:06 2010
> > New Revision: 917149
> >
> > URL: http://svn.apache.org/viewvc?rev=917149&view=rev
> > Log:
> > [MANTTASKS-178] fixed pom properties resolution to be compatible with
> > both Ant 1.6 to 1.7.1 property intercepter API and the new Ant 1.8.0
> > property delegate API
>
> Thanks Hervé, works like a charm :-) !
>
>
> Benjamin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: svn commit: r917149 - in /maven/ant-tasks/trunk: ./ src/it/ant-run-plugin-with-ant-1.8.0/
src/main/java/org/apache/maven/artifact/ant/
Posted by Benjamin Bentmann <be...@udo.edu>.
> Author: hboutemy
> Date: Sun Feb 28 09:41:06 2010
> New Revision: 917149
>
> URL: http://svn.apache.org/viewvc?rev=917149&view=rev
> Log:
> [MANTTASKS-178] fixed pom properties resolution to be compatible with both Ant 1.6 to 1.7.1 property intercepter API and the new Ant 1.8.0 property delegate API
Thanks Hervé, works like a charm :-) !
Benjamin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org