o Refactored code

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@808344 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-27 09:55:02 +00:00
parent 3842d802e4
commit 5ab104e063
2 changed files with 21 additions and 15 deletions

View File

@ -211,7 +211,7 @@ public class DefaultLifecycleExecutor
logger.debug( "-----------------------------------------------------------------------" );
logger.debug( "Goal: " + mojoExecId );
logger.debug( "Style: "
+ ( isAggregatorMojo( mojoExecution.getMojoDescriptor() ) ? "Aggregating" : "Regular" ) );
+ ( mojoExecution.getMojoDescriptor().isAggregating() ? "Aggregating" : "Regular" ) );
logger.debug( "Configuration: " + mojoExecution.getConfiguration() );
}
@ -643,7 +643,7 @@ public class DefaultLifecycleExecutor
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, session.getTopLevelProject() );
boolean aggregating = isAggregatorMojo( mojoDescriptor );
boolean aggregating = mojoDescriptor.isAggregating();
if ( currentSegment == null || currentSegment.aggregating != aggregating )
{
@ -675,17 +675,6 @@ public class DefaultLifecycleExecutor
return task.indexOf( ':' ) >= 0;
}
private boolean isAggregatorMojo( MojoDescriptor mojoDescriptor )
{
return mojoDescriptor.isAggregator() || !mojoDescriptor.isProjectRequired();
}
private boolean isForkingMojo( MojoDescriptor mojoDescriptor )
{
return StringUtils.isNotEmpty( mojoDescriptor.getExecuteGoal() )
|| StringUtils.isNotEmpty( mojoDescriptor.getExecutePhase() );
}
private static final class ProjectBuild
{
@ -906,7 +895,7 @@ public class DefaultLifecycleExecutor
{
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
if ( !isForkingMojo( mojoDescriptor ) )
if ( !mojoDescriptor.isForking() )
{
return;
}
@ -918,7 +907,7 @@ public class DefaultLifecycleExecutor
List<MavenProject> forkedProjects;
if ( isAggregatorMojo( mojoDescriptor ) )
if ( mojoDescriptor.isAggregating() )
{
forkedProjects = session.getProjects();
}

View File

@ -616,6 +616,23 @@ public class MojoDescriptor
return executeGoal;
}
/**
* @return {@code true} if this mojo is aggregating projects, {@code false} otherwise.
*/
public boolean isAggregating()
{
return isAggregator() || !isProjectRequired();
}
/**
* @return {@code true} if this mojo forks either a goal or the lifecycle, {@code false} otherwise.
*/
public boolean isForking()
{
return ( getExecuteGoal() != null && getExecuteGoal().length() > 0 )
|| ( getExecutePhase() != null && getExecutePhase().length() > 0 );
}
/**
* Creates a shallow copy of this mojo descriptor.
*/