mojoDescriptor.setImplementation( javaClass.getFullyQualifiedName() );
mojoDescriptor.setDescription( javaClass.getComment() );
DocletTag tag = findInClassHierarchy( javaClass, MAVEN_PLUGIN_INSTANTIATION );
if ( tag != null )
{
mojoDescriptor.setInstantiationStrategy( tag.getValue() );
}
tag = findInClassHierarchy( javaClass, GOAL_MULTI_EXECUTION_STRATEGY );
if ( tag != null )
{
mojoDescriptor.setExecutionStrategy( MojoDescriptor.MULTI_PASS_EXEC_STRATEGY );
}
else
{
mojoDescriptor.setExecutionStrategy( MojoDescriptor.SINGLE_PASS_EXEC_STRATEGY );
}
// ----------------------------------------------------------------------
// Configurator hint
// ----------------------------------------------------------------------
DocletTag configurator = findInClassHierarchy( javaClass, CONFIGURATOR );
if ( configurator != null )
{
mojoDescriptor.setComponentConfigurator( configurator.getValue() );
}
// ----------------------------------------------------------------------
// Goal name
// ----------------------------------------------------------------------
DocletTag goal = findInClassHierarchy( javaClass, GOAL );
if ( goal != null )
{
mojoDescriptor.setGoal( goal.getValue() );
}
// ----------------------------------------------------------------------
// Phase name
// ----------------------------------------------------------------------
DocletTag phase = findInClassHierarchy( javaClass, PHASE );
if ( phase != null )
{
mojoDescriptor.setPhase( phase.getValue() );
}
// ----------------------------------------------------------------------
// Additional phase to execute first
// ----------------------------------------------------------------------
DocletTag execute = findInClassHierarchy( javaClass, EXECUTE );
if ( execute != null )
{
String executePhase = execute.getNamedParameter( "phase" );
String executeGoal = execute.getNamedParameter( "goal" );
if ( executePhase == null && executeGoal == null )
{
throw new InvalidPluginDescriptorException( "@execute tag requires a 'phase' or 'goal' parameter" );
}
else if ( executePhase != null && executeGoal != null )
{
throw new InvalidPluginDescriptorException(
"@execute tag can have only one of a 'phase' or 'goal' parameter" );
}
mojoDescriptor.setExecutePhase( executePhase );
mojoDescriptor.setExecuteGoal( executeGoal );
String lifecycle = execute.getNamedParameter( "lifecycle" );
if ( lifecycle != null )
{
mojoDescriptor.setExecuteLifecycle( lifecycle );
if ( mojoDescriptor.getExecuteGoal() != null )
{
throw new InvalidPluginDescriptorException(
"@execute lifecycle requires a phase instead of a goal" );
}
}
}
// ----------------------------------------------------------------------
// Dependency resolution flag
// ----------------------------------------------------------------------
DocletTag requiresDependencyResolution = findInClassHierarchy( javaClass, GOAL_REQUIRES_DEPENDENCY_RESOLUTION );
if ( requiresDependencyResolution != null )
{
String value = requiresDependencyResolution.getValue();
if ( value == null || value.length() == 0 )
{
value = "runtime";
}
mojoDescriptor.setDependencyResolutionRequired( value );
}
// ----------------------------------------------------------------------
// Project flag
// ----------------------------------------------------------------------
boolean value = getBooleanTagValue( javaClass, GOAL_REQUIRES_PROJECT, mojoDescriptor.isProjectRequired() );
mojoDescriptor.setProjectRequired( value );
// ----------------------------------------------------------------------
// Aggregator flag
// ----------------------------------------------------------------------
DocletTag aggregator = findInClassHierarchy( javaClass, GOAL_IS_AGGREGATOR );
if ( aggregator != null )
{
mojoDescriptor.setAggregator( true );
}