mirror of https://github.com/apache/maven.git
Working on the compat aspect, and changing the DefaultMaven class to implement LogEnabled directly so I can grab the logger instance inside the compat aspect...AbstractLogEnabled is beyond the grasp of this aspect.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@602610 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a104251412
commit
1328959dca
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue