mirror of https://github.com/apache/maven.git
PR: MNG-1057
look for command line goals in the project declared plugins git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@292935 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
39cd577f77
commit
76f82eefc9
|
@ -1144,14 +1144,14 @@ public class DefaultLifecycleExecutor
|
|||
StringTokenizer tok = new StringTokenizer( task, ":" );
|
||||
int numTokens = tok.countTokens();
|
||||
|
||||
// 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 msg = "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 + "\')";
|
||||
throw new LifecycleExecutionException( msg );
|
||||
}
|
||||
|
||||
String prefix = tok.nextToken();
|
||||
|
@ -1159,16 +1159,9 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
// Steps for retrieving the plugin model instance:
|
||||
// 1. request directly from the plugin collector by prefix
|
||||
try
|
||||
{
|
||||
pluginDescriptor = pluginManager.getPluginDescriptorForPrefix( prefix );
|
||||
}
|
||||
catch ( PluginManagerException e )
|
||||
{
|
||||
throw new LifecycleExecutionException(
|
||||
"Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin collector.", e );
|
||||
}
|
||||
|
||||
// 2. look in the repository via search groups
|
||||
if ( pluginDescriptor == null )
|
||||
{
|
||||
try
|
||||
|
@ -1181,8 +1174,7 @@ public class DefaultLifecycleExecutor
|
|||
"Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin mappings metadata.", e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( pluginDescriptor != null )
|
||||
else
|
||||
{
|
||||
plugin = new Plugin();
|
||||
|
||||
|
@ -1191,7 +1183,34 @@ public class DefaultLifecycleExecutor
|
|||
plugin.setVersion( pluginDescriptor.getVersion() );
|
||||
}
|
||||
|
||||
// 2. default to o.a.m.plugins and maven-<prefix>-plugin
|
||||
// 3. search plugins in the current POM
|
||||
if ( plugin == null )
|
||||
{
|
||||
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
|
||||
{
|
||||
Plugin buildPlugin = (Plugin) i.next();
|
||||
|
||||
try
|
||||
{
|
||||
PluginDescriptor desc = pluginManager.verifyPlugin( buildPlugin, project, session.getSettings(),
|
||||
session.getLocalRepository() );
|
||||
if ( prefix.equals( desc.getGoalPrefix() ) )
|
||||
{
|
||||
plugin = buildPlugin;
|
||||
}
|
||||
}
|
||||
catch ( PluginManagerException e )
|
||||
{
|
||||
throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
|
||||
}
|
||||
catch ( PluginVersionResolutionException e )
|
||||
{
|
||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. default to o.a.m.plugins and maven-<prefix>-plugin
|
||||
if ( plugin == null )
|
||||
{
|
||||
plugin = new Plugin();
|
||||
|
|
|
@ -131,7 +131,6 @@ public class DefaultPluginManager
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
public PluginDescriptor getPluginDescriptorForPrefix( String prefix )
|
||||
throws PluginManagerException
|
||||
{
|
||||
return pluginCollector.getPluginDescriptorForPrefix( prefix );
|
||||
}
|
||||
|
@ -313,15 +312,17 @@ public class DefaultPluginManager
|
|||
|
||||
// NOTE: I'm putting these checks in here, since this is the central point of access for
|
||||
// anything that wants to execute a mojo.
|
||||
if( mojoDescriptor.isProjectRequired() && !session.isUsingPOMsFromFilesystem() )
|
||||
if ( mojoDescriptor.isProjectRequired() && !session.isUsingPOMsFromFilesystem() )
|
||||
{
|
||||
throw new MojoExecutionException( "Cannot execute mojo: " + mojoDescriptor.getGoal() + ". It requires a project, but the build is not using one." );
|
||||
throw new MojoExecutionException( "Cannot execute mojo: " + mojoDescriptor.getGoal() +
|
||||
". It requires a project, but the build is not using one." );
|
||||
}
|
||||
|
||||
if ( mojoDescriptor.isOnlineRequired() && session.getSettings().isOffline() )
|
||||
{
|
||||
// TODO: Should we error out, or simply warn and skip??
|
||||
throw new MojoExecutionException( "Mojo: " + mojoDescriptor.getGoal() + " requires online mode for execution. Maven is currently offline." );
|
||||
throw new MojoExecutionException( "Mojo: " + mojoDescriptor.getGoal() +
|
||||
" requires online mode for execution. Maven is currently offline." );
|
||||
}
|
||||
|
||||
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
|
||||
|
|
|
@ -44,8 +44,7 @@ public interface PluginManager
|
|||
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
||||
throws PluginManagerException;
|
||||
|
||||
PluginDescriptor getPluginDescriptorForPrefix( String prefix )
|
||||
throws PluginManagerException;
|
||||
PluginDescriptor getPluginDescriptorForPrefix( String prefix );
|
||||
|
||||
Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
|
||||
throws PluginManagerException;
|
||||
|
|
Loading…
Reference in New Issue