maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r1074184 - in /maven/maven-3/trunk: maven-core/src/main/java/org/apache/maven/plugin/ maven-core/src/main/java/org/apache/maven/plugin/internal/ maven-embedder/src/main/java/org/apache/maven/cli/
Date Thu, 24 Feb 2011 15:12:30 GMT
Author: bentmann
Date: Thu Feb 24 15:12:30 2011
New Revision: 1074184

URL: http://svn.apache.org/viewvc?rev=1074184&view=rev
Log:
[MNG-5019] [regression] String-based component lookups performed by report mojos fail with
ClassCastException

Modified:
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java
    maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java?rev=1074184&r1=1074183&r2=1074184&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java
Thu Feb 24 15:12:30 2011
@@ -24,7 +24,6 @@ import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
@@ -40,9 +39,6 @@ public class DefaultBuildPluginManager
 {
 
     @Requirement
-    private PlexusContainer container;
-
-    @Requirement
     private MavenPluginManager mavenPluginManager;
 
     @Requirement
@@ -86,8 +82,6 @@ public class DefaultBuildPluginManager
             throw new PluginExecutionException( mojoExecution, project, e );
         }
 
-        ClassRealm oldLookupRealm = container.setLookupRealm( pluginRealm );
-
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader( pluginRealm );
 
@@ -159,7 +153,6 @@ public class DefaultBuildPluginManager
             mavenPluginManager.releaseMojo( mojo, mojoExecution );
 
             Thread.currentThread().setContextClassLoader( oldClassLoader );
-            container.setLookupRealm( oldLookupRealm );
 
             legacySupport.setSession( oldSession );
         }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java?rev=1074184&r1=1074183&r2=1074184&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginManager.java
Thu Feb 24 15:12:30 2011
@@ -109,16 +109,16 @@ public class DefaultPluginManager
             throw new PluginManagerException( plugin, e.getMessage(), e );
         }
 
-        ClassRealm oldRealm = container.getLookupRealm();
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         try
         {
-            container.setLookupRealm( pluginDescriptor.getClassRealm() );
+            Thread.currentThread().setContextClassLoader( pluginDescriptor.getClassRealm()
);
 
             return container.lookup( role, roleHint );
         }
         finally
         {
-            container.setLookupRealm( oldRealm );
+            Thread.currentThread().setContextClassLoader( oldClassLoader );
         }
     }
 
@@ -141,16 +141,16 @@ public class DefaultPluginManager
             throw new PluginManagerException( plugin, e.getMessage(), e );
         }
 
-        ClassRealm oldRealm = container.getLookupRealm();
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         try
         {
-            container.setLookupRealm( pluginDescriptor.getClassRealm() );
+            Thread.currentThread().setContextClassLoader( pluginDescriptor.getClassRealm()
);
 
             return container.lookupMap( role );
         }
         finally
         {
-            container.setLookupRealm( oldRealm );
+            Thread.currentThread().setContextClassLoader( oldClassLoader );
         }
     }
 

Modified: maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java?rev=1074184&r1=1074183&r2=1074184&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java (original)
+++ maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java Thu
Feb 24 15:12:30 2011
@@ -374,6 +374,9 @@ public class MavenCli
 
             container = new DefaultPlexusContainer( cc );
 
+            // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups
+            container.setLookupRealm( null );
+
             container.setLoggerManager( new MavenLoggerManager( logger ) );
 
             customizeContainer( container );



Mime
View raw message