Hi,

I recently came across this situation in my own project where I wanted to
skip some plugin executions during a standard maven build. I could not find
a straight forward way to accomplish this (as described in MNG-3321) and so
thought of implementing this feature.

I checked out the source yesterday and after some analysis here are my two
options about going to implement this feature:

Option 1:

1. The 
DefaultLifecycleExecutionPlanCalculator<http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java?revision=1061589&view=markup>'s
calculateLifecycleMappings method computes the applicable executions for a
given life cycle phase. This method also has access to the MavenSession
which holds the user supplied properties. So, a property like
-Dskip.plugin:org.apache.maven.plugins:maven-surefire-plugin is available to
this method.
2. Line 256 of this method loops over all plugins of the current project and
for each plugin, it extracts all the applicable executions (depending on the
life cycle phase) and returns these executions.
3. It is here that I would like to introduce this skip filtering. Basically
consult the MavenSession for every plugin/execution and check if its
supposed to be skipped. If yes, then *do not* add it to the returned list of
executions.

Option 2:

1. The 
DefaultBuildPluginManager<http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java?revision=1042237&view=markup>'s
executeMojo method executes the given MojoExecution. This method also has
access to the MavenSession which holds the user supplied properties.
2. I can introduce a guard clause at line 73, to check against the session
and determine if this execution be skipped or not.

To me both options seem viable for implementation but I might be missing
something. In case you prefer any specific option or if there's a simpler
way to do this, will you please point them out.

Sincere Regards,
Kalyan C. Akella

Reply via email to