diff --git a/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj b/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj index f4357b9622..6d961bbd85 100644 --- a/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj +++ b/maven-core/src/main/aspect/org/apache/maven/compat/plugin/Maven20xCompatAspect.aj @@ -1,5 +1,6 @@ package org.apache.maven.compat.plugin; +import org.apache.maven.DefaultMaven; import org.apache.maven.lifecycle.MojoBindingUtils; import org.apache.maven.lifecycle.LifecycleUtils; import org.apache.maven.lifecycle.NoSuchPhaseException; @@ -36,7 +37,6 @@ import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LogEnabled; import java.io.IOException; import java.util.Iterator; @@ -87,15 +87,19 @@ public privileged aspect Maven20xCompatAspect // capture the session instance. after( MavenSession session ): sessionCreation( session ) { + if ( logger != null && logger.isDebugEnabled() ) + { + logger.debug( "Capturing session for backward compatibility aspect: " + session ); + } + this.session = session; } // USE Session to compensate for old verifyPlugin(..) API. private pointcut verifyPlugin( Plugin plugin, MavenProject project, PluginManager manager ): - execution( public PluginDescriptor PluginManager+.verifyPlugin( Plugin, MavenProject, Settings, ArtifactRepository ) ) + execution( PluginDescriptor PluginManager+.verifyPlugin( Plugin, MavenProject, Settings, ArtifactRepository+ ) ) && args( plugin, project, .. ) - && target( manager ) - && notHere(); + && target( manager ); // redirect the old verifyPlugin(..) call to the new one, using the captured session instance above. PluginDescriptor around( Plugin plugin, @@ -106,6 +110,11 @@ public privileged aspect Maven20xCompatAspect PluginVersionNotFoundException: verifyPlugin( plugin, project, manager ) { + if ( logger != null && logger.isDebugEnabled() ) + { + logger.debug( "Diverting legacy PluginManager.verifyPlugin(..) call to replacement method using session: " + session ); + } + return manager.verifyPlugin( plugin, project, session ); } @@ -114,18 +123,12 @@ public privileged aspect Maven20xCompatAspect MavenProject project, Settings settings, ArtifactRepository localRepository ) + throws ArtifactResolutionException, ArtifactNotFoundException, PluginNotFoundException, + PluginVersionResolutionException, InvalidPluginException, PluginManagerException, + PluginVersionNotFoundException { // this will always be diverted, so no need to do anything. - return null; - } - - public PluginDescriptor DefaultPluginManager.verifyPlugin( Plugin plugin, - MavenProject project, - Settings settings, - ArtifactRepository localRepository ) - { - // this will always be diverted, so no need to do anything. - return null; + throw new IllegalStateException( "This introduced method should ALWAYS be intercepted by backward compatibility aspect." ); } private pointcut getPluginDescriptorForPrefix( String prefix, PluginManager manager ): @@ -266,15 +269,13 @@ public privileged aspect Maven20xCompatAspect return pluginRealm; } - private pointcut enableLoggingCall( Logger logger ): - execution( void LogEnabled+.enableLogging( Logger ) ) - && args( logger ); - - after( Logger logger ): enableLoggingCall( logger ) + before( DefaultMaven maven ): + execution( MavenExecutionResult DefaultMaven.execute( MavenExecutionRequest ) ) + && this( maven ) { if ( this.logger == null ) { - this.logger = logger; + this.logger = maven.getLogger(); } } diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index a6515ebe60..a7264cfd5a 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -47,7 +47,8 @@ import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.logging.LogEnabled; +import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.Os; @@ -68,9 +69,8 @@ import java.util.List; * @todo EventDispatcher should be a component as it is internal to maven. */ public class DefaultMaven - extends AbstractLogEnabled implements Maven, - Contextualizable + Contextualizable, LogEnabled { // ---------------------------------------------------------------------- // Components @@ -86,6 +86,8 @@ public class DefaultMaven private BuildExtensionScanner buildExtensionScanner; + private Logger logger; + // ---------------------------------------------------------------------- // Project execution // ---------------------------------------------------------------------- @@ -501,4 +503,14 @@ public class DefaultMaven } } } + + protected Logger getLogger() + { + return logger; + } + + public void enableLogging( Logger logger ) + { + this.logger = logger; + } }