From 23097a37a068b3052a615fa903ad84d5dfa9aa4f Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Sun, 14 Oct 2012 09:46:54 +0000 Subject: [PATCH] [MNG-5350] improved warning message: when in debug mode, list the goals and not only the plugins git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1398044 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/lifecycle/MavenExecutionPlan.java | 26 ++++++++++++++++++- .../lifecycle/internal/BuilderCommon.java | 25 +++++++++++++----- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java b/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java index 79a913b54a..a1d1cb4008 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/MavenExecutionPlan.java @@ -32,6 +32,7 @@ import java.util.Set; import org.apache.maven.lifecycle.internal.ExecutionPlanItem; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.descriptor.MojoDescriptor; //TODO: lifecycles being executed //TODO: what runs in each phase @@ -170,7 +171,11 @@ public class MavenExecutionPlan return result; } - + /** + * Get set of plugins having a goal/mojo used but not marked @threadSafe + * + * @return the set of plugins (without info on which goal is concerned) + */ public Set getNonThreadSafePlugins() { Set plugins = new HashSet(); @@ -185,6 +190,25 @@ public class MavenExecutionPlan return plugins; } + /** + * Get set of mojos used but not marked @threadSafe + * + * @return the set of mojo descriptors + */ + public Set getNonThreadSafeMojos() + { + Set mojos = new HashSet(); + for ( ExecutionPlanItem executionPlanItem : planItem ) + { + final MojoExecution mojoExecution = executionPlanItem.getMojoExecution(); + if ( !mojoExecution.getMojoDescriptor().isThreadSafe() ) + { + mojos.add( mojoExecution.getMojoDescriptor() ); + } + } + return mojos; + } + // Used by m2e but will be removed, really. @Deprecated public List getExecutions() diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuilderCommon.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuilderCommon.java index 92dc6910e3..2e63647487 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuilderCommon.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/BuilderCommon.java @@ -35,6 +35,7 @@ import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; +import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; @@ -69,7 +70,6 @@ public class BuilderCommon private Logger logger; - @SuppressWarnings( { "UnusedDeclaration" } ) public BuilderCommon() { } @@ -101,17 +101,30 @@ public class BuilderCommon { logger.warn( "*****************************************************************" ); logger.warn( "* Your build is requesting parallel execution, but project *" ); - logger.warn( "* contains the following plugin(s) that are not marked as *" ); - logger.warn( "* @threadSafe to support parallel building. *" ); + logger.warn( "* contains the following plugin(s) that have goals not marked *" ); + logger.warn( "* as @threadSafe to support parallel building. *" ); logger.warn( "* While this /may/ work fine, please look for plugin updates *" ); logger.warn( "* and/or request plugins be made thread-safe. *" ); logger.warn( "* If reporting an issue, report it against the plugin in *" ); logger.warn( "* question, not against maven-core *" ); logger.warn( "*****************************************************************" ); - logger.warn( "The following plugins are not marked @threadSafe in " + project.getName() + ":" ); - for ( Plugin unsafePlugin : unsafePlugins ) + if ( logger.isDebugEnabled() ) { - logger.warn( unsafePlugin.getId() ); + final Set unsafeGoals = executionPlan.getNonThreadSafeMojos(); + logger.warn( "The following goals are not marked @threadSafe in " + project.getName() + ":" ); + for ( MojoDescriptor unsafeGoal : unsafeGoals ) + { + logger.warn( unsafeGoal.getId() ); + } + } + else + { + logger.warn( "The following plugins are not marked @threadSafe in " + project.getName() + ":" ); + for ( Plugin unsafePlugin : unsafePlugins ) + { + logger.warn( unsafePlugin.getId() ); + } + logger.warn( "Enable debug to see more precisely which goals are not marked @threadSafe." ); } logger.warn( "*****************************************************************" ); }