}
else
{
String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or" +
" a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal";
throw new BuildFailureException( message );
}
if ( plugin.getVersion() == null )
{
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
{
Plugin buildPlugin = (Plugin) i.next();
if ( buildPlugin.getKey().equals( plugin.getKey() ) )
{
plugin = buildPlugin;
break;
}
}
project.injectPluginManagementInfo( plugin );
}
if ( pluginDescriptor == null )
{
pluginDescriptor = verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() );
}
// this has been simplified from the old code that injected the plugin management stuff, since
// pluginManagement injection is now handled by the project method.
project.addPlugin( plugin );
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
if ( mojoDescriptor == null )
{
if ( isOptionalMojo )
{
getLogger().info( "Skipping missing optional mojo: " + task );
}
else
{
throw new BuildFailureException( "Required goal not found: " + task + " in "
+ pluginDescriptor.getId() );
}
}
return mojoDescriptor;