diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
index 9d470930c1..ec3cb26ba0 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
@@ -365,7 +365,7 @@ public class DefaultLifecycleExecutor
try
{
// definitely a CLI goal, can use prefix
- mojo = getMojoDescriptor( task, session, project, true );
+ mojo = getMojoDescriptor( task, session, project, task, true );
}
catch ( LifecycleExecutionException e )
{
@@ -449,7 +449,7 @@ public class DefaultLifecycleExecutor
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException
{
// guaranteed to come from the CLI and not be part of a phase
- MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, true );
+ MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true );
executeGoals( Collections.singletonList( new MojoExecution( mojoDescriptor ) ), session, project );
}
@@ -570,7 +570,7 @@ public class DefaultLifecycleExecutor
// Not from the CLI, don't use prefix
// TODO: [MNG-608] this needs to be false
- MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session, project, true );
+ MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session, project, selectedPhase, false );
addToLifecycleMappings( lifecycleMappings, phase, new MojoExecution( mojoDescriptor ),
session.getSettings() );
}
@@ -851,7 +851,7 @@ public class DefaultLifecycleExecutor
}
private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project,
- boolean canUsePrefixes )
+ String invokedVia, boolean canUsePrefix )
throws ArtifactResolutionException, LifecycleExecutionException
{
String goal;
@@ -861,8 +861,15 @@ public class DefaultLifecycleExecutor
StringTokenizer tok = new StringTokenizer( task, ":" );
int numTokens = tok.countTokens();
- if ( numTokens == 2 && canUsePrefixes )
+
+ // TODO: Add "&& canUsePrefix" to this boolean expression, and remove deprecation warning in next release.
+ if ( numTokens == 2 )
{
+ if ( !canUsePrefix )
+ {
+ getLogger().warn( "DEPRECATED: Mapped-prefix lookup of mojos are only supported from direct invocation. Please use specification of the form groupId:artifactId[:version]:goal instead. (Offending mojo: \'" + task + "\', invoked via: \'" + invokedVia + "\')" );
+ }
+
String prefix = tok.nextToken();
goal = tok.nextToken();
@@ -919,13 +926,17 @@ public class DefaultLifecycleExecutor
}
}
}
- else if ( numTokens == 4 )
+ else if ( numTokens == 3 || numTokens == 4 )
{
plugin = new Plugin();
plugin.setGroupId( tok.nextToken() );
plugin.setArtifactId( tok.nextToken() );
- plugin.setVersion( tok.nextToken() );
+
+ if ( numTokens == 4 )
+ {
+ plugin.setVersion( tok.nextToken() );
+ }
goal = tok.nextToken();
}
diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml
index a91016aeeb..78b3d8acf6 100644
--- a/maven-core/src/main/resources/META-INF/plexus/components.xml
+++ b/maven-core/src/main/resources/META-INF/plexus/components.xml
@@ -162,14 +162,17 @@
- resources:resources
- compiler:compile
- resources:testResources
- compiler:testCompile
- surefire:test
- jar:jar,source:jar
- install:install
- deploy:deploy
+ org.apache.maven.plugins:maven-resources-plugin:resources
+ org.apache.maven.plugins:maven-compiler-plugin:compile
+ org.apache.maven.plugins:maven-resources-plugin:testResources
+ org.apache.maven.plugins:maven-compiler-plugin:testCompile
+ org.apache.maven.plugins:maven-surefire-plugin:test
+
+ org.apache.maven.plugins:maven-jar-plugin:jar,
+ org.apache.maven.plugins:maven-source-plugin:jar
+
+ org.apache.maven.plugins:maven-install-plugin:install
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
@@ -185,8 +188,8 @@
- install:install
- deploy:deploy
+ org.apache.maven.plugins:maven-install-plugin:install
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
@@ -199,14 +202,17 @@
- resources:resources
- compiler:compile
- resources:testResources
- compiler:testCompile
- surefire:test
- jar:jar,source:jar
- install:install
- deploy:deploy
+ org.apache.maven.plugins:maven-resources-plugin:resources
+ org.apache.maven.plugins:maven-compiler-plugin:compile
+ org.apache.maven.plugins:maven-resources-plugin:testResources
+ org.apache.maven.plugins:maven-compiler-plugin:testCompile
+ org.apache.maven.plugins:maven-surefire-plugin:test
+
+ org.apache.maven.plugins:maven-jar-plugin:jar,
+ org.apache.maven.plugins:maven-source-plugin:jar
+
+ org.apache.maven.plugins:maven-install-plugin:install
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
@@ -219,15 +225,24 @@
- plugin:descriptor
- resources:resources
- compiler:compile
- resources:testResources
- compiler:testCompile
- surefire:test
- jar:jar,plugin:addPluginArtifactMetadata
- install:install,plugin:installMapping
- deploy:deploy,plugin:deployMapping
+ org.apache.maven.plugins:maven-plugin-plugin:descriptor
+ org.apache.maven.plugins:maven-resources-plugin:resources
+ org.apache.maven.plugins:maven-compiler-plugin:compile
+ org.apache.maven.plugins:maven-resources-plugin:testResources
+ org.apache.maven.plugins:maven-compiler-plugin:testCompile
+ org.apache.maven.plugins:maven-surefire-plugin:test
+
+ org.apache.maven.plugins:maven-jar-plugin:jar,
+ org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata
+
+
+ org.apache.maven.plugins:maven-install-plugin:install,
+ org.apache.maven.plugins:maven-plugin-plugin:installMapping
+
+
+ org.apache.maven.plugins:maven-deploy-plugin:deploy,
+ org.apache.maven.plugins:maven-plugin-plugin:deployMapping
+
@@ -240,14 +255,17 @@
- resources:resources
- compiler:compile
- resources:testResources
- compiler:testCompile
- surefire:test
- ejb:ejb,source:jar
- install:install
- deploy:deploy
+ org.apache.maven.plugins:maven-resources-plugin:resources
+ org.apache.maven.plugins:maven-compiler-plugin:compile
+ org.apache.maven.plugins:maven-resources-plugin:testResources
+ org.apache.maven.plugins:maven-compiler-plugin:testCompile
+ org.apache.maven.plugins:maven-surefire-plugin:test
+
+ org.apache.maven.plugins:maven-ejb-plugin:ejb,
+ org.apache.maven.plugins:maven-source-plugin:jar
+
+ org.apache.maven.plugins:maven-install-plugin:install
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
@@ -260,14 +278,14 @@
- resources:resources
- compiler:compile
- resources:testResources
- compiler:testCompile
- surefire:test
- war:war
- install:install
- deploy:deploy
+ org.apache.maven.plugins:maven-resources-plugin:resources
+ org.apache.maven.plugins:maven-compiler-plugin:compile
+ org.apache.maven.plugins:maven-resources-plugin:testResources
+ org.apache.maven.plugins:maven-compiler-plugin:testCompile
+ org.apache.maven.plugins:maven-surefire-plugin:test
+ org.apache.maven.plugins:maven-war-plugin:war
+ org.apache.maven.plugins:maven-install-plugin:install
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
@@ -280,10 +298,10 @@
- ear:generate-application-xml
- ear:ear
- install:install
- deploy:deploy
+ org.apache.maven.plugins:maven-ear-plugin:generate-application-xml
+ org.apache.maven.plugins:maven-ear-plugin:ear
+ org.apache.maven.plugins:maven-install-plugin:install
+ org.apache.maven.plugins:maven-deploy-plugin:deploy