}
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 );
}
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 );
}
}
return mojoDescriptor;
}