From 27698689a8ed2afacca0368ca3289069b08624b9 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Wed, 31 Oct 2007 17:26:37 +0000 Subject: [PATCH] Adding compat trailer to the maven version when it's printed via the cli. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@590758 13f79535-47bb-0310-9956-ffa450edef68 --- .../compat/plugin/Maven20xCompatAspect.aj | 44 ++++++++++++++++--- maven-embedder/pom.xml | 26 +++++++++++ 2 files changed, 63 insertions(+), 7 deletions(-) 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 76d7c3b0ec..5609e3f09e 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 @@ -28,18 +28,43 @@ import org.apache.maven.settings.Settings; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.IOException; +import java.io.PrintStream; import java.util.Iterator; -import java.util.LinkedHashSet; import java.util.Set; public privileged aspect Maven20xCompatAspect { + // pointcut to avoid recursive matching on behavior injected by this aspect. + private pointcut notHere(): !within( Maven20xCompatAspect ); + + private pointcut showVersion( PrintStream stream, String string): + cflow( execution( void org.apache.maven.cli.CLIReportingUtils.showVersion() ) ) + && call( void PrintStream.println( String ) ) + && args( string ) + && target( stream ) + && notHere(); + + void around( PrintStream stream, String string ): showVersion( stream, string ) + { + if ( stream == System.out && string != null && string.startsWith( "Maven version:" ) ) + { + System.out.println( string + " (compat enabled)" ); + } + else + { + proceed( stream, string ); + } + } + // GRAB Session and Request. private MavenSession session; private MavenExecutionRequest request; - private pointcut sessionCreation( MavenSession session ): execution( public MavenSession.new(..) ) && this( session ); + private pointcut sessionCreation( MavenSession session ): + execution( public MavenSession.new(..) ) + && this( session ) + && notHere(); after( MavenSession session ): sessionCreation( session ) { @@ -48,7 +73,8 @@ public privileged aspect Maven20xCompatAspect private pointcut methodsTakingRequest( MavenExecutionRequest request ): execution( MavenExecutionResult *.*( MavenExecutionRequest ) ) - && args( request ); + && args( request ) + && notHere(); before( MavenExecutionRequest request ): methodsTakingRequest( request ) { @@ -59,7 +85,8 @@ public privileged aspect Maven20xCompatAspect private pointcut verifyPlugin( Plugin plugin, MavenProject project, PluginManager manager ): call( public PluginDescriptor PluginManager+.verifyPlugin( Plugin, MavenProject, Settings, ArtifactRepository ) ) && args( plugin, project, .. ) - && target( manager ); + && target( manager ) + && notHere(); PluginDescriptor around( Plugin plugin, MavenProject project, @@ -86,7 +113,8 @@ public privileged aspect Maven20xCompatAspect private pointcut extDepArtifactsResolved( DefaultExtensionManager mgr ): call( public Set ResolutionGroup.getArtifacts() ) && within( DefaultExtensionManager ) - && this( mgr ); + && this( mgr ) + && notHere(); Set around( DefaultExtensionManager mgr ): extDepArtifactsResolved( mgr ) { @@ -101,7 +129,8 @@ public privileged aspect Maven20xCompatAspect private pointcut pluginDepArtifactsResolved( DefaultPluginManager mgr ): call( public Set ResolutionGroup.getArtifacts() ) && cflow( execution( Set DefaultPluginManager.getPluginArtifacts(..) ) ) - && this( mgr ); + && this( mgr ) + && notHere(); Set around( DefaultPluginManager mgr ): pluginDepArtifactsResolved( mgr ) { @@ -115,7 +144,8 @@ public privileged aspect Maven20xCompatAspect // USE Request to compensate for old buildSettings() API. private pointcut buildSettings( MavenSettingsBuilder builder ): execution( public Settings MavenSettingsBuilder+.buildSettings() ) - && target( builder ); + && target( builder ) + && notHere(); Settings around( MavenSettingsBuilder builder ) throws IOException, XmlPullParserException: diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml index 8bb5c7cce0..5db6d2da03 100644 --- a/maven-embedder/pom.xml +++ b/maven-embedder/pom.xml @@ -86,6 +86,32 @@ under the License. 1.5.3 + + + + + org.codehaus.mojo + aspectj-maven-plugin + + + + weave-compat + + compile + + + + + org.apache.maven + maven-core + + + + + + + +