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, ":" );
|
StringTokenizer tok = new StringTokenizer( task, ":" );
|
||||||
int numTokens = tok.countTokens();
|
int numTokens = tok.countTokens();
|
||||||
|
|
||||||
// TODO: Add "&& canUsePrefix" to this boolean expression, and remove deprecation warning in next release.
|
|
||||||
if ( numTokens == 2 )
|
if ( numTokens == 2 )
|
||||||
{
|
{
|
||||||
if ( !canUsePrefix )
|
if ( !canUsePrefix )
|
||||||
{
|
{
|
||||||
getLogger().warn(
|
String msg = "DEPRECATED: Mapped-prefix lookup of mojos are only supported from direct invocation. " +
|
||||||
"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: \'" +
|
"Please use specification of the form groupId:artifactId[:version]:goal instead. " +
|
||||||
task + "\', invoked via: \'" + invokedVia + "\')" );
|
"(Offending mojo: \'" + task + "\', invoked via: \'" + invokedVia + "\')";
|
||||||
|
throw new LifecycleExecutionException( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
String prefix = tok.nextToken();
|
String prefix = tok.nextToken();
|
||||||
|
@ -1159,16 +1159,9 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
// Steps for retrieving the plugin model instance:
|
// Steps for retrieving the plugin model instance:
|
||||||
// 1. request directly from the plugin collector by prefix
|
// 1. request directly from the plugin collector by prefix
|
||||||
try
|
pluginDescriptor = pluginManager.getPluginDescriptorForPrefix( prefix );
|
||||||
{
|
|
||||||
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 )
|
if ( pluginDescriptor == null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1181,8 +1174,7 @@ public class DefaultLifecycleExecutor
|
||||||
"Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin mappings metadata.", e );
|
"Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin mappings metadata.", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if ( pluginDescriptor != null )
|
|
||||||
{
|
{
|
||||||
plugin = new Plugin();
|
plugin = new Plugin();
|
||||||
|
|
||||||
|
@ -1191,7 +1183,34 @@ public class DefaultLifecycleExecutor
|
||||||
plugin.setVersion( pluginDescriptor.getVersion() );
|
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 )
|
if ( plugin == null )
|
||||||
{
|
{
|
||||||
plugin = new Plugin();
|
plugin = new Plugin();
|
||||||
|
|
|
@ -131,7 +131,6 @@ public class DefaultPluginManager
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public PluginDescriptor getPluginDescriptorForPrefix( String prefix )
|
public PluginDescriptor getPluginDescriptorForPrefix( String prefix )
|
||||||
throws PluginManagerException
|
|
||||||
{
|
{
|
||||||
return pluginCollector.getPluginDescriptorForPrefix( prefix );
|
return pluginCollector.getPluginDescriptorForPrefix( prefix );
|
||||||
}
|
}
|
||||||
|
@ -310,18 +309,20 @@ public class DefaultPluginManager
|
||||||
throws ArtifactResolutionException, PluginManagerException, MojoExecutionException
|
throws ArtifactResolutionException, PluginManagerException, MojoExecutionException
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||||
|
|
||||||
// NOTE: I'm putting these checks in here, since this is the central point of access for
|
// NOTE: I'm putting these checks in here, since this is the central point of access for
|
||||||
// anything that wants to execute a mojo.
|
// 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() )
|
if ( mojoDescriptor.isOnlineRequired() && session.getSettings().isOffline() )
|
||||||
{
|
{
|
||||||
// TODO: Should we error out, or simply warn and skip??
|
// 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 )
|
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
|
||||||
|
@ -503,7 +504,7 @@ public class DefaultPluginManager
|
||||||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
|
|
||||||
PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );
|
PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );
|
||||||
|
|
||||||
// if this is the first time this plugin has been used, the plugin's container will only
|
// if this is the first time this plugin has been used, the plugin's container will only
|
||||||
// contain the plugin's artifact in isolation; we need to finish resolving the plugin's
|
// contain the plugin's artifact in isolation; we need to finish resolving the plugin's
|
||||||
// dependencies, and add them to the container.
|
// dependencies, and add them to the container.
|
||||||
|
@ -519,10 +520,10 @@ public class DefaultPluginManager
|
||||||
if ( plugin instanceof ContextEnabled )
|
if ( plugin instanceof ContextEnabled )
|
||||||
{
|
{
|
||||||
Map pluginContext = session.getPluginContext( pluginDescriptor, project );
|
Map pluginContext = session.getPluginContext( pluginDescriptor, project );
|
||||||
|
|
||||||
( (ContextEnabled) plugin ).setPluginContext( pluginContext );
|
( (ContextEnabled) plugin ).setPluginContext( pluginContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.setLog( mojoLogger );
|
plugin.setLog( mojoLogger );
|
||||||
|
|
||||||
XmlPlexusConfiguration pomConfiguration;
|
XmlPlexusConfiguration pomConfiguration;
|
||||||
|
|
|
@ -44,8 +44,7 @@ public interface PluginManager
|
||||||
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
||||||
throws PluginManagerException;
|
throws PluginManagerException;
|
||||||
|
|
||||||
PluginDescriptor getPluginDescriptorForPrefix( String prefix )
|
PluginDescriptor getPluginDescriptorForPrefix( String prefix );
|
||||||
throws PluginManagerException;
|
|
||||||
|
|
||||||
Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
|
Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
|
||||||
throws PluginManagerException;
|
throws PluginManagerException;
|
||||||
|
|
Loading…
Reference in New Issue