You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/06/22 01:25:28 UTC

svn commit: r191744 - in /maven/components/trunk/maven-artifact-ant: ./ src/main/java/org/apache/maven/artifact/ant/ src/main/resources/META-INF/plexus/

Author: jdcasey
Date: Tue Jun 21 16:25:26 2005
New Revision: 191744

URL: http://svn.apache.org/viewcvs?rev=191744&view=rev
Log:
Resolving issue: MNG-467 (patch from Kenney Westerhof applied, with minor formatting modifications)
Resolving issue: MNG-503 (another patch from Kenney Westerhof applied)

o Tracked down the potential NPE when using a list of dependencies in the DependencyTask (it needs a Pom in order to create an originating artifact)...creating a dummy Pom instance when the list of dependencies is supplied, since I assume the originatingArtifact is used for tracking/graphing purposes. This new method, called createDummyPom() is in AbstractArtifactTask, so it's available for use in InstallTask and DeployTask if necessary...

Thanks, Kenney!


Modified:
    maven/components/trunk/maven-artifact-ant/sample.build.xml
    maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
    maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
    maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java
    maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml

Modified: maven/components/trunk/maven-artifact-ant/sample.build.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/sample.build.xml?rev=191744&r1=191743&r2=191744&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/sample.build.xml (original)
+++ maven/components/trunk/maven-artifact-ant/sample.build.xml Tue Jun 21 16:25:26 2005
@@ -1,13 +1,46 @@
-<project name="foo" xmlns:artifact="antlib:org.apache.maven.artifact.ant" default="foo">
-  <target name="test-pom">
+<project name="foo" default="foo" xmlns:artifact="urn:maven-artifact-ant">
+  <!--
+    You either need to run the the 'initTaskDefs' task below and
+    define the artifact namespace like above (choose anything you
+    like except strings that start with 'antlib:'),
+    and be sure to supply the path to the maven-artifact-ant jars
+
+    OR
+
+    just define the artifact namespace as follows:
+
+      xmlns:artifact="antlib:org.apache.maven.artifact.ant"
+
+    and be sure to add the maven-artifact-ant jars to the ant
+    classpath (either by setting the CLASSPATH environment variable
+    before calling ant, or place the jars in the $ANT_HOME/lib directory).
+
+  -->
+
+  <target name="initTaskDefs">
+    <!-- don't forget to set the value! -->
+    <property name="maven.artifact-ant.lib.dir" value="${user.home}/work/opensource/m2/maven-artifact-ant/target/"/>
+    <path id="maven.classpath">
+      <pathelement location="${maven.artifact-ant.lib.dir}/maven-artifact-ant-2.0-SNAPSHOT-dep.jar"/>
+      <pathelement location="${maven.artifact-ant.lib.dir}maven-artifact-ant-2.0-SNAPSHOT.jar"/>
+    </path>
+
+    <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
+      uri="urn:maven-artifact-ant"
+    >
+      <classpath refid="maven.classpath"/>
+    </typedef>
+  </target>
+
+  <target name="test-pom" depends="initTaskDefs">
     <artifact:pom file="pom.xml" id="my.maven.project"/>
 
-    <echo>Artifact ID = ${my.maven.project:artifactId}</echo>
+    <echo>Artifact ID = ${my.maven.project.artifactId}</echo>
 
-    <echo>Parent Artifact ID = ${my.maven.project:parent.artifactId}</echo>
+    <echo>Parent Artifact ID = ${my.maven.project.parent.artifactId}</echo>
   </target>
 
-  <target name="foo">
+  <target name="foo" depends="initTaskDefs">
     <artifact:localRepository id="local.repository" location="${basedir}/target/local-repo" layout="default"/>
 
     <artifact:remoteRepository id="deploy.repository" url="file://${basedir}/target/deployment-repo" layout="legacy"/>
@@ -51,7 +84,7 @@
     </artifact:deploy>
   </target>
 
-  <target name="test-scm">
+  <target name="test-scm" depends="initTaskDefs">
     <mkdir dir="target" />
 
     <pathconvert targetos="unix" property="repo.path.unix">

Modified: maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?rev=191744&r1=191743&r2=191744&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java Tue Jun 21 16:25:26 2005
@@ -27,11 +27,16 @@
 import org.apache.maven.settings.Server;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
+import org.apache.maven.model.Model;
 import org.apache.maven.profiles.activation.ProfileActivationUtils;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
+import org.codehaus.classworlds.ClassRealm;
+import org.codehaus.classworlds.ClassWorld;
+import org.codehaus.classworlds.DuplicateRealmException;
 import org.codehaus.plexus.PlexusContainerException;
 import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -251,14 +256,24 @@
             if ( embedder == null )
             {
                 embedder = new Embedder();
+
                 try
                 {
-                    embedder.start();
+                    ClassWorld classWorld = new ClassWorld();
+                    
+                    ClassRealm classRealm = classWorld.newRealm( "plexus.core", getClass().getClassLoader() );
+                    
+                    embedder.start( classWorld );
                 }
                 catch ( PlexusContainerException e )
                 {
                     throw new BuildException( "Unable to start embedder", e );
                 }
+                catch ( DuplicateRealmException e )
+                {
+                    throw new BuildException( "Unable to create embedder ClassRealm", e );
+                }
+                
                 getProject().addReference( Embedder.class.getName(), embedder );
             }
         }
@@ -286,6 +301,24 @@
         {
             pom.initialise( projectBuilder, localArtifactRepository );
         }
+        return pom;
+    }
+
+    protected Pom createDummyPom()
+    {
+        Model mavenModel = new Model();
+        
+        mavenModel.setGroupId( "unspecified" );
+        mavenModel.setArtifactId( "unspecified" );
+        mavenModel.setVersion( "0.0" );
+        mavenModel.setPackaging( "jar" );
+        
+        MavenProject mavenProject = new MavenProject( mavenModel );
+        
+        Pom pom = new Pom();
+        
+        pom.setMavenProject( mavenProject );
+        
         return pom;
     }
 

Modified: maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?rev=191744&r1=191743&r2=191744&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java Tue Jun 21 16:25:26 2005
@@ -81,6 +81,12 @@
                 remoteRepositories.add( createAntRemoteRepository( pomRepository ) );
             }
         }
+        else
+        {
+            // we have to have some sort of Pom object in order to satisfy the requirements for building the
+            // originating Artifact below...
+            pom = createDummyPom();
+        }
 
         Set artifacts = metadataSource.createArtifacts( dependencies, null, null );
 

Modified: maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java?rev=191744&r1=191743&r2=191744&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/java/org/apache/maven/artifact/ant/Pom.java Tue Jun 21 16:25:26 2005
@@ -91,6 +91,11 @@
         }
         return instance;
     }
+    
+    public void setMavenProject( MavenProject mavenProject )
+    {
+        getInstance().mavenProject = mavenProject;
+    }
 
     public File getFile()
     {

Modified: maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml?rev=191744&r1=191743&r2=191744&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml Tue Jun 21 16:25:26 2005
@@ -229,7 +229,7 @@
           <role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.profiless.activation.ProfileActivationCalculator</role>
+          <role>org.apache.maven.profiles.activation.ProfileActivationCalculator</role>
         </requirement>
       </requirements>
     </component>
@@ -239,8 +239,8 @@
      |
      -->
     <component>
-      <role>org.apache.maven.profiless.activation.ProfileActivationCalculator</role>
-      <implementation>org.apache.maven.profiless.activation.ProfileActivationCalculator</implementation>
+      <role>org.apache.maven.profiles.activation.ProfileActivationCalculator</role>
+      <implementation>org.apache.maven.profiles.activation.ProfileActivationCalculator</implementation>
     </component>
     <!--
      |
@@ -248,9 +248,9 @@
      |
      -->
     <component>
-      <role>org.apache.maven.profiless.activation.ProfileActivator</role>
+      <role>org.apache.maven.profiles.activation.ProfileActivator</role>
       <role-hint>always-on</role-hint>
-      <implementation>org.apache.maven.profiless.activation.AlwaysOnProfileActivator</implementation>
+      <implementation>org.apache.maven.profiles.activation.AlwaysOnProfileActivator</implementation>
     </component>
     <!--
      |
@@ -258,9 +258,9 @@
      |
      -->
     <component>
-      <role>org.apache.maven.profiless.activation.ProfileActivator</role>
+      <role>org.apache.maven.profiles.activation.ProfileActivator</role>
       <role-hint>jdk-prefix</role-hint>
-      <implementation>org.apache.maven.profiless.activation.JdkPrefixProfileActivator</implementation>
+      <implementation>org.apache.maven.profiles.activation.JdkPrefixProfileActivator</implementation>
     </component>
     <!--
      |
@@ -268,9 +268,9 @@
      |
      -->
     <component>
-      <role>org.apache.maven.profiless.activation.ProfileActivator</role>
+      <role>org.apache.maven.profiles.activation.ProfileActivator</role>
       <role-hint>system-property</role-hint>
-      <implementation>org.apache.maven.profiless.activation.SystemPropertyProfileActivator</implementation>
+      <implementation>org.apache.maven.profiles.activation.SystemPropertyProfileActivator</implementation>
     </component>
     <!--
      |
@@ -278,9 +278,9 @@
      |
      -->
     <component>
-      <role>org.apache.maven.profiless.activation.ProfileActivator</role>
+      <role>org.apache.maven.profiles.activation.ProfileActivator</role>
       <role-hint>explicit-listing</role-hint>
-      <implementation>org.apache.maven.profiless.activation.ExplicitListingProfileActivator</implementation>
+      <implementation>org.apache.maven.profiles.activation.ExplicitListingProfileActivator</implementation>
     </component>
     <!--
      |



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org