maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r587648 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/plugin/ maven-embedder/src/test/java/org/apache/maven/embedder/
Date Tue, 23 Oct 2007 20:33:11 GMT
Author: jvanzyl
Date: Tue Oct 23 13:33:10 2007
New Revision: 587648

URL: http://svn.apache.org/viewvc?rev=587648&view=rev
Log:
o for milos' test i am now adding the component to the container programmatically so we don't
need to manually stuff an artifact handler into
  the artifact handler manager

Added:
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MyArtifactHandler.java
  (with props)
Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=587648&r1=587647&r2=587648&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Tue Oct 23 13:33:10 2007
@@ -1400,9 +1400,8 @@
 
         if ( pluginRealm == null )
         {
-            getLogger().warn(
-                              "getPluginComponent(" + plugin + ", " + role
-                                              + "): descriptor is missing classRealm" );
+            getLogger().warn( "getPluginComponent(" + plugin + ", " + role + "): descriptor
is missing classRealm" );
+            
             pluginRealm = container.getLookupRealm();
         }
 

Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java?rev=587648&r1=587647&r2=587648&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderProjectWithExtensionReadingTest.java
Tue Oct 23 13:33:10 2007
@@ -1,16 +1,17 @@
 package org.apache.maven.embedder;
 
-import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionResult;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.PluginManagerException;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.codehaus.plexus.component.repository.ComponentDescriptor;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 
 import java.io.File;
 import java.util.Map;
-import java.util.HashMap;
 
 /** @author Jason van Zyl */
 public class MavenEmbedderProjectWithExtensionReadingTest
@@ -24,7 +25,25 @@
 
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
 
-        MavenExecutionResult result = new ExtendableMavenEmbedder( classLoader ).readProjectWithDependencies(
request );
+        MavenEmbedder embedder = new ExtendableMavenEmbedder( classLoader );
+
+        // Here we take the artifact handler and programmatically place it into the container
+
+        ComponentDescriptor cd = new ComponentDescriptor();
+
+        cd.setRole( ArtifactHandler.ROLE );
+
+        cd.setRoleHint( "mkleint" );
+
+        cd.setImplementation( MyArtifactHandler.class.getName() );
+
+        embedder.getPlexusContainer().addComponentDescriptor( cd );
+
+        // At this point the artifact handler will be inside the container and 
+        // Maven internally will pick up the artifact handler and use it accordingly to
+        // create the classpath appropriately.
+
+        MavenExecutionResult result = embedder.readProjectWithDependencies( request );
 
         assertNoExceptions( result );
 
@@ -48,13 +67,17 @@
         protected Map getPluginExtensionComponents( Plugin plugin )
             throws PluginManagerException
         {
-            Map toReturn = new HashMap();
+            try
+            {
+                return getPlexusContainer().lookupMap( ArtifactHandler.ROLE );
+            }
+            catch ( ComponentLookupException e )
+            {
+                e.printStackTrace();
 
-            MyArtifactHandler handler = new MyArtifactHandler();
+                throw new PluginManagerException( plugin, null );
+            }
 
-            toReturn.put( "mkleint", handler );
-
-            return toReturn;
         }
 
         protected void verifyPlugin( Plugin plugin,
@@ -64,43 +87,4 @@
         }
     }
 
-    private class MyArtifactHandler
-        implements ArtifactHandler
-    {
-
-        public String getExtension()
-        {
-            return "jar";
-        }
-
-        public String getDirectory()
-        {
-            throw new UnsupportedOperationException( "Not supported yet." );
-        }
-
-        public String getClassifier()
-        {
-            return null;
-        }
-
-        public String getPackaging()
-        {
-            return "mkleint";
-        }
-
-        public boolean isIncludesDependencies()
-        {
-            return false;
-        }
-
-        public String getLanguage()
-        {
-            return "java";
-        }
-
-        public boolean isAddedToClasspath()
-        {
-            return true;
-        }
-    }    
 }

Added: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MyArtifactHandler.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MyArtifactHandler.java?rev=587648&view=auto
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MyArtifactHandler.java
(added)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MyArtifactHandler.java
Tue Oct 23 13:33:10 2007
@@ -0,0 +1,43 @@
+package org.apache.maven.embedder;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+
+/** @author Jason van Zyl */
+public class MyArtifactHandler
+    implements ArtifactHandler
+{
+    public String getExtension()
+    {
+        return "jar";
+    }
+
+    public String getDirectory()
+    {
+        throw new UnsupportedOperationException( "Not supported yet." );
+    }
+
+    public String getClassifier()
+    {
+        return null;
+    }
+
+    public String getPackaging()
+    {
+        return "mkleint";
+    }
+
+    public boolean isIncludesDependencies()
+    {
+        return false;
+    }
+
+    public String getLanguage()
+    {
+        return "java";
+    }
+
+    public boolean isAddedToClasspath()
+    {
+        return true;
+    }
+}

Propchange: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MyArtifactHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MyArtifactHandler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message