From 5ab104e0630b739a55a0cf30fd1ffb377ed60a01 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Thu, 27 Aug 2009 09:55:02 +0000 Subject: [PATCH] o Refactored code git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@808344 13f79535-47bb-0310-9956-ffa450edef68 --- .../lifecycle/DefaultLifecycleExecutor.java | 19 ++++--------------- .../plugin/descriptor/MojoDescriptor.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 5dfab5606d..025b418823 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -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 forkedProjects; - if ( isAggregatorMojo( mojoDescriptor ) ) + if ( mojoDescriptor.isAggregating() ) { forkedProjects = session.getProjects(); } diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java index d86f52d240..f39b2036f1 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java @@ -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. */