Author: jdcasey Date: Thu Mar 15 21:25:05 2007 New Revision: 518859 URL: http://svn.apache.org/viewvc?view=rev&rev=518859 Log: Adding javadocs and some design doco (UML).
Added: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-class-diagram.png (with props) maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-sequence-diagram.png (with props) maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor.graffle (with props) Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LegacyLifecycleMappingParser.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanModifier.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanUtils.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationModifier.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationOriginElement.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkPlanModifier.java maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkedDirectInvocationModifier.java Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Thu Mar 15 21:25:05 2007 @@ -83,7 +83,7 @@ private PluginLoader pluginLoader; - private BuildPlanner lifecyclePlanner; + private BuildPlanner buildPlanner; private ArtifactHandlerManager artifactHandlerManager; @@ -178,11 +178,16 @@ dispatcher.dispatchStart( event, target ); + // NEW: To support forked execution under the new lifecycle architecture, the current project + // is stored in a build-context managed data type. This context type holds the current project + // for the fork being executed, plus a stack of projects used in the ancestor execution contexts. LifecycleExecutionContext ctx = new LifecycleExecutionContext( rootProject ); ctx.store( buildContextManager ); + // NEW: Build up the execution plan, including configuration. List mojoBindings = getLifecycleBindings( segment.getTasks(), rootProject, target ); + // NEW: Then, iterate over each binding in that plan, and execute the associated mojo. // only call once, with the top-level project (assumed to be provided as a parameter)... for ( Iterator mojoIterator = mojoBindings.iterator(); mojoIterator.hasNext(); ) { @@ -192,6 +197,7 @@ target ); } + // clean up the execution context, so we don't pollute for future project-executions. LifecycleExecutionContext.delete( buildContextManager ); rm.registerBuildSuccess( rootProject, System.currentTimeMillis() - buildStartTime ); @@ -279,13 +285,19 @@ } } + /** + * Retrieves the build plan for the current project, given the specified list of tasks. This + * build plan will consist of MojoBindings, each fully configured to execute, which enables us + * to enumerate the full build plan to the debug log-level, complete with the configuration each + * mojo will use. + */ private List getLifecycleBindings( List tasks, MavenProject project, String targetDescription ) throws LifecycleExecutionException { List mojoBindings; try { - BuildPlan plan = lifecyclePlanner.constructLifecyclePlan( tasks, project ); + BuildPlan plan = buildPlanner.constructBuildPlan( tasks, project ); if ( getLogger().isDebugEnabled() ) { @@ -307,9 +319,14 @@ long buildStartTime, String target ) throws BuildFailureException, LifecycleExecutionException { + // NEW: Retrieve/use the current project stored in the execution context, for consistency. LifecycleExecutionContext ctx = LifecycleExecutionContext.read( buildContextManager ); MavenProject project = ctx.getCurrentProject(); + // NEW: Since the MojoBinding instances are configured when the build plan is constructed, + // all that remains to be done here is to load the PluginDescriptor, construct a MojoExecution + // instance, and call PluginManager.executeMojo( execution ). The MojoExecutor is constructed + // using both the PluginDescriptor and the MojoBinding. try { PluginDescriptor pluginDescriptor = null; Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java Thu Mar 15 21:25:05 2007 @@ -20,9 +20,20 @@ import java.util.Iterator; import java.util.Map; +/** + * Set of utilities used to create and manipulate MojoBindings, both singly and in collections that + * constitute LifecycleBindings instances. Some of the methods contained here have fairly generic + * names, but have a specialized purpose for this package (such as those that build plugin keys + * that lack the version); therefore, this class and all of its methods are package-scoped. + */ final class BindingUtils { + /** + * Builds a mapping of groupId:artifactId --> Plugin from the POM. If a plugin is listed + * without a groupId, the [EMAIL PROTECTED] BindingUtils#createPluginKey(Plugin)} method will fill it in + * using org.apache.maven.plugins. + */ static Map buildPluginMap( MavenProject project ) { Map pluginMap = new HashMap(); @@ -44,6 +55,11 @@ return pluginMap; } + /** + * Builds a mapping of groupId:artifactId --> Plugin from a PluginContainer, such as the build + * or pluginManagement section of a POM. If a plugin is listed without a groupId, the + * [EMAIL PROTECTED] BindingUtils#createPluginKey(Plugin)} method will fill it in using org.apache.maven.plugins. + */ static Map buildPluginMap( PluginContainer pluginContainer ) { Map pluginMap = new HashMap(); @@ -61,21 +77,38 @@ return pluginMap; } + /** + * Create a key for the given Plugin, for use in mappings. The key consists of groupId:artifactId, + * where groupId == org.apache.maven.plugins if the Plugin instance has a groupId == null. + */ static String createPluginKey( Plugin plugin ) { return createPluginKey( plugin.getGroupId(), plugin.getArtifactId() ); } + /** + * Create a key for use in looking up Plugin instances from mappings. The key consists of + * groupId:artifactId, where groupId == org.apache.maven.plugins if the supplied groupId + * value == null. + */ static String createPluginKey( String groupId, String artifactId ) { return ( groupId == null ? PluginDescriptor.getDefaultPluginGroupId() : groupId ) + ":" + artifactId; } + /** + * Merge the ReportPlugin and ReportSet configurations, with the ReportSet configuration taking + * precedence. + */ static Object mergeConfigurations( ReportPlugin reportPlugin, ReportSet reportSet ) { return mergeRawConfigurations( reportSet.getConfiguration(), reportPlugin.getConfiguration() ); } + /** + * Merge the Plugin and PluginExecution configurations, with the PluginExecution configuration + * taking precedence. + */ static Object mergeConfigurations( Plugin plugin, PluginExecution execution ) { if ( plugin == null && execution == null ) @@ -96,6 +129,11 @@ } } + /** + * Merge two configurations, assuming they are Xpp3Dom instances. This method creates a defensive + * copy of the dominant configuration before merging, to avoid polluting the original dominant + * one. + */ static Object mergeRawConfigurations( Object dominant, Object recessive ) { Xpp3Dom dominantConfig = (Xpp3Dom) dominant; @@ -115,6 +153,10 @@ } } + /** + * Inject any plugin configuration available from the specified POM into the MojoBinding, after + * first merging in the applicable configuration from the POM's pluginManagement section. + */ static void injectProjectConfiguration( MojoBinding binding, MavenProject project ) { Map pluginMap = buildPluginMap( project ); @@ -134,6 +176,11 @@ binding.setConfiguration( mergeConfigurations( plugin, exec ) ); } + /** + * Inject any plugin configuration available from the specified POM into the MojoBindings + * present in the given LifecycleBindings instance, after first merging in the configuration + * from the POM's pluginManagement section. + */ static void injectProjectConfiguration( LifecycleBindings bindings, MavenProject project ) { Map pluginsByVersionlessKey = buildPluginMap( project ); @@ -170,6 +217,10 @@ } } + /** + * Inject any applicable configuration available from the POM's pluginManagement section into the + * specified Plugin instance. + */ static void injectPluginManagementInfo( Plugin plugin, MavenProject project ) { if ( project == null ) Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java Thu Mar 15 21:25:05 2007 @@ -36,7 +36,15 @@ import java.util.Map; import java.util.StringTokenizer; -//FIXME: This needs a better name! +/** + * Responsible for the gross construction of LifecycleBindings, or mappings of MojoBinding instances + * to different parts of the three lifecycles: clean, build, and site. Also, handles transcribing + * these LifecycleBindings instances into lists of MojoBinding's, which can be consumed by the + * LifecycleExecutor. + * + * @author jdcasey + * + */ public class DefaultLifecycleBindingManager implements LifecycleBindingManager, LogEnabled { @@ -59,6 +67,11 @@ // configured. Moved out of DefaultLifecycleExecutor... private List defaultReports; + /** + * Retrieve the LifecycleBindings given by the lifecycle mapping component/file for the project's + * packaging. Any applicable mojo configuration will be injected into the LifecycleBindings from + * the POM. + */ public LifecycleBindings getBindingsForPackaging( MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException { @@ -99,6 +112,13 @@ return bindings; } + /** + * Search all plugins configured in the POM that have extensions == true, looking for either a + * [EMAIL PROTECTED] LifecycleBindingLoader} instance, or a [EMAIL PROTECTED] LifecycleMapping} instance that matches + * the project's packaging. For the first match found, construct the corresponding LifecycleBindings + * instance and return it after POM configurations have been injected into any appropriate + * MojoBinding instances contained within. + */ private LifecycleBindings searchPluginsWithExtensions( MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException { @@ -176,6 +196,10 @@ return bindings; } + /** + * Construct the LifecycleBindings for the default lifecycle mappings, including injection of + * configuration from the project into each MojoBinding, where appropriate. + */ public LifecycleBindings getDefaultBindings( MavenProject project ) throws LifecycleSpecificationException { @@ -191,6 +215,10 @@ this.logger = logger; } + /** + * Construct the LifecycleBindings that constitute the extra mojos bound to the lifecycle within + * the POM itself. + */ public LifecycleBindings getProjectCustomBindings( MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException { @@ -269,6 +297,11 @@ return bindings; } + /** + * Construct the LifecycleBindings that constitute the mojos mapped to the lifecycles by an overlay + * specified in a plugin. Inject mojo configuration from the POM into all appropriate MojoBinding + * instances. + */ public LifecycleBindings getPluginLifecycleOverlay( PluginDescriptor pluginDescriptor, String lifecycleId, MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException @@ -385,6 +418,18 @@ return bindings; } + /** + * Retrieve the list of MojoBinding instances that correspond to the reports configured for the + * specified project. Inject all appropriate configuration from the POM for each MojoBinding, using + * the following precedence rules: + * <br/> + * <ol> + * <li>report-set-level configuration</li> + * <li>reporting-level configuration</li> + * <li>execution-level configuration</li> + * <li>plugin-level configuration</li> + * </ol> + */ public List getReportBindings( MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException { @@ -422,6 +467,9 @@ return reports; } + /** + * Retrieve the ReportPlugin instances referenced in the specified POM. + */ private List getReportPluginsForProject( MavenProject project ) { List reportPlugins = project.getReportPlugins(); @@ -475,6 +523,9 @@ return reportPlugins; } + /** + * Retrieve any reports from the specified ReportPlugin which are referenced in the specified POM. + */ private List getReportsForPlugin( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project ) throws LifecycleLoaderException { @@ -545,7 +596,12 @@ return reports; } - static boolean isSameOrSuperListOfMojoBindings( List superCandidate, List check ) + /** + * Determine whether the first list contains all of the same MojoBinding instances, in the same + * order, starting at index zero, as the second list. If so, it is either a perfect super-list + * or an equal list, and return true. Return false otherwise. + */ + private static boolean isSameOrSuperListOfMojoBindings( List superCandidate, List check ) { if ( superCandidate == null || check == null ) { @@ -576,12 +632,32 @@ return superKeys.subList( 0, checkKeys.size() ).equals( checkKeys ); } + /** + * Traverse the specified LifecycleBindings instance for all of the specified tasks. If the task + * is found to be a phase name, construct the list of all MojoBindings that lead up to that phase + * in that lifecycle, and add them to the master MojoBinding list. If the task is not a phase name, + * treat it as a direct mojo invocation, parse it into a MojoBinding (resolving the plugin prefix + * first if necessary), and add it to the master MojoBinding list. Finally, return the master list. + */ public List assembleMojoBindingList( List tasks, LifecycleBindings bindings, MavenProject project ) throws LifecycleSpecificationException, LifecyclePlannerException, LifecycleLoaderException { return assembleMojoBindingList( tasks, bindings, Collections.EMPTY_MAP, project ); } + /** + * Traverse the specified LifecycleBindings instance for all of the specified tasks. If the task + * is found to be a phase name, construct the list of all MojoBindings that lead up to that phase + * in that lifecycle, and add them to the master MojoBinding list. If the task is not a phase name, + * treat it as a direct mojo invocation, parse it into a MojoBinding (resolving the plugin prefix + * first if necessary), and add it to the master MojoBinding list. + * + * Then, iterate through all MojoBindings in the master list, and for each one that maps to an + * entry in directInvocationModifiers, substitute the resultant MojoBinding list from that + * modifier in place of the original MojoBinding. + * + * Finally, return the modified master list. + */ public List assembleMojoBindingList( List tasks, LifecycleBindings lifecycleBindings, Map directInvocationModifiers, MavenProject project ) throws LifecycleSpecificationException, LifecyclePlannerException, LifecycleLoaderException Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java Thu Mar 15 21:25:05 2007 @@ -10,12 +10,24 @@ import java.util.StringTokenizer; +/** + * Responsible for constructing or parsing MojoBinding instances from one of several sources, potentially + * using the [EMAIL PROTECTED] PluginLoader} to resolve any plugin prefixes first. + * + * @author jdcasey + * + */ public class DefaultMojoBindingFactory implements MojoBindingFactory { PluginLoader pluginLoader; + /** + * Parse the specified mojo string into a MojoBinding, optionally allowing plugin-prefix references. + * If a plugin-prefix is allowed and used, resolve the prefix and use the resulting PluginDescriptor + * to set groupId and artifactId on the MojoBinding instance. + */ public MojoBinding parseMojoBinding( String bindingSpec, MavenProject project, boolean allowPrefixReference ) throws LifecycleSpecificationException, LifecycleLoaderException { @@ -79,6 +91,10 @@ return binding; } + /** + * Create a new MojoBinding instance with the specified information, and inject POM configurations + * appropriate to that mojo before returning it. + */ public MojoBinding createMojoBinding( String groupId, String artifactId, String version, String goal, MavenProject project ) { MojoBinding binding = new MojoBinding(); @@ -93,6 +109,11 @@ return binding; } + /** + * Simplified version of [EMAIL PROTECTED] MojoBindingFactory#parseMojoBinding(String, MavenProject, boolean)} + * which assumes the project is null and prefixes are not allowed. This method will <b>never</b> + * result in the [EMAIL PROTECTED] PluginLoader} being used to resolve the PluginDescriptor. + */ public MojoBinding parseMojoBinding( String bindingSpec ) throws LifecycleSpecificationException { Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LegacyLifecycleMappingParser.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LegacyLifecycleMappingParser.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LegacyLifecycleMappingParser.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LegacyLifecycleMappingParser.java Thu Mar 15 21:25:05 2007 @@ -16,6 +16,13 @@ import java.util.Map; import java.util.StringTokenizer; +/** + * Responsible for parsing the Maven-2.0.x lifecycle-definition syntaxes. This class is partitioned + * from the others, because this syntax should be deprecated and removed from support, eventually. + * + * @author jdcasey + * + */ public class LegacyLifecycleMappingParser { Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java Thu Mar 15 21:25:05 2007 @@ -10,30 +10,88 @@ import java.util.List; import java.util.Map; -// FIXME: This needs a better name! +/** + * Responsible for the gross construction of LifecycleBindings, or mappings of MojoBinding instances + * to different parts of the three lifecycles: clean, build, and site. Also, handles transcribing + * these LifecycleBindings instances into lists of MojoBinding's, which can be consumed by the + * LifecycleExecutor. + * + * @author jdcasey + * + */ public interface LifecycleBindingManager { String ROLE = LifecycleBindingManager.class.getName(); + /** + * Construct the LifecycleBindings for the default lifecycle mappings, including injection of + * configuration from the project into each MojoBinding, where appropriate. + */ LifecycleBindings getDefaultBindings( MavenProject project ) throws LifecycleSpecificationException; + /** + * Retrieve the LifecycleBindings given by the lifecycle mapping component/file for the project's + * packaging. Any applicable mojo configuration will be injected into the LifecycleBindings from + * the POM. + */ LifecycleBindings getBindingsForPackaging( MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException; + /** + * Construct the LifecycleBindings that constitute the extra mojos bound to the lifecycle within + * the POM itself. + */ LifecycleBindings getProjectCustomBindings( MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException; + /** + * Construct the LifecycleBindings that constitute the mojos mapped to the lifecycles by an overlay + * specified in a plugin. Inject mojo configuration from the POM into all appropriate MojoBinding + * instances. + */ LifecycleBindings getPluginLifecycleOverlay( PluginDescriptor pluginDescriptor, String lifecycleId, MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException; + /** + * Retrieve the list of MojoBinding instances that correspond to the reports configured for the + * specified project. Inject all appropriate configuration from the POM for each MojoBinding, using + * the following precedence rules: + * <br/> + * <ol> + * <li>report-set-level configuration</li> + * <li>reporting-level configuration</li> + * <li>execution-level configuration</li> + * <li>plugin-level configuration</li> + * </ol> + */ List getReportBindings( MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException; + /** + * Traverse the specified LifecycleBindings instance for all of the specified tasks. If the task + * is found to be a phase name, construct the list of all MojoBindings that lead up to that phase + * in that lifecycle, and add them to the master MojoBinding list. If the task is not a phase name, + * treat it as a direct mojo invocation, parse it into a MojoBinding (resolving the plugin prefix + * first if necessary), and add it to the master MojoBinding list. + * + * Then, iterate through all MojoBindings in the master list, and for each one that maps to an + * entry in directInvocationModifiers, substitute the resultant MojoBinding list from that + * modifier in place of the original MojoBinding. + * + * Finally, return the modified master list. + */ List assembleMojoBindingList( List tasks, LifecycleBindings bindings, Map directInvocationModifiers, MavenProject project ) throws LifecycleSpecificationException, LifecyclePlannerException, LifecycleLoaderException; + /** + * Traverse the specified LifecycleBindings instance for all of the specified tasks. If the task + * is found to be a phase name, construct the list of all MojoBindings that lead up to that phase + * in that lifecycle, and add them to the master MojoBinding list. If the task is not a phase name, + * treat it as a direct mojo invocation, parse it into a MojoBinding (resolving the plugin prefix + * first if necessary), and add it to the master MojoBinding list. Finally, return the master list. + */ List assembleMojoBindingList( List tasks, LifecycleBindings lifecycleBindings, MavenProject project ) throws LifecycleSpecificationException, LifecyclePlannerException, LifecycleLoaderException; Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java Thu Mar 15 21:25:05 2007 @@ -3,18 +3,40 @@ import org.apache.maven.lifecycle.LifecycleLoaderException; import org.apache.maven.lifecycle.LifecycleSpecificationException; import org.apache.maven.lifecycle.model.MojoBinding; +import org.apache.maven.plugin.loader.PluginLoader; import org.apache.maven.project.MavenProject; +/** + * Responsible for constructing or parsing MojoBinding instances from one of several sources, potentially + * using the [EMAIL PROTECTED] PluginLoader} to resolve any plugin prefixes first. + * + * @author jdcasey + * + */ public interface MojoBindingFactory { String ROLE = MojoBindingFactory.class.getName(); + /** + * Parse the specified mojo string into a MojoBinding, optionally allowing plugin-prefix references. + * If a plugin-prefix is allowed and used, resolve the prefix and use the resulting PluginDescriptor + * to set groupId and artifactId on the MojoBinding instance. + */ MojoBinding parseMojoBinding( String bindingSpec, MavenProject project, boolean allowPrefixReference ) throws LifecycleSpecificationException, LifecycleLoaderException; + /** + * Create a new MojoBinding instance with the specified information, and inject POM configurations + * appropriate to that mojo before returning it. + */ MojoBinding createMojoBinding( String groupId, String artifactId, String version, String goal, MavenProject project ); + /** + * Simplified version of [EMAIL PROTECTED] MojoBindingFactory#parseMojoBinding(String, MavenProject, boolean)} + * which assumes the project is null and prefixes are not allowed. This method will <b>never</b> + * result in the [EMAIL PROTECTED] PluginLoader} being used to resolve the PluginDescriptor. + */ MojoBinding parseMojoBinding( String bindingSpec ) throws LifecycleSpecificationException; Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanModifier.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanModifier.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanModifier.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanModifier.java Thu Mar 15 21:25:05 2007 @@ -2,9 +2,18 @@ import org.apache.maven.lifecycle.model.LifecycleBindings; +/** + * Modifies an existing set of lifecycle mojo bindings, in order to inject extra behavior, such as + * forked executions, reporting, etc. + */ public interface BuildPlanModifier extends ModifiablePlanElement { + /** + * Inject any modifications into the given LifecycleBindings provided by the build plan. In some + * cases, it may be necessary to regenerate the LifecycleBindings instance, so the altered instance + * is returned separately. + */ LifecycleBindings modifyBindings( LifecycleBindings bindings ) throws LifecyclePlannerException; Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanUtils.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanUtils.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanUtils.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanUtils.java Thu Mar 15 21:25:05 2007 @@ -13,6 +13,10 @@ import java.util.Iterator; import java.util.List; +/** + * Collection of static utility methods used to work with LifecycleBindings and other collections + * of MojoBinding instances that make up a build plan. + */ public final class BuildPlanUtils { @@ -20,6 +24,13 @@ { } + /** + * Inject a set of [EMAIL PROTECTED] BuildPlanModifier} instances into an existing LifecycleBindings instance. + * This is a generalization of a piece of code present in almost all scenarios where a build + * plan contains modifiers and is asked to produce an effective list of MojoBinding instances + * that make up the build process. Simply iterate through the modifiers, and apply each one, + * replacing the previous LifecycleBindings instance with the result of the current modifier. + */ public static LifecycleBindings modifyPlanBindings( LifecycleBindings bindings, List planModifiers ) throws LifecyclePlannerException { @@ -46,12 +57,10 @@ return result; } - public static String listBuildPlan( BuildPlan plan, MavenProject project, LifecycleBindingManager lifecycleBindingManager ) - throws LifecycleSpecificationException, LifecyclePlannerException, LifecycleLoaderException - { - return listBuildPlan( plan, project, lifecycleBindingManager, false ); - } - + /** + * Render an entire build plan to a String. + * If extendedInfo == true, include each MojoBinding's configuration in the output. + */ public static String listBuildPlan( BuildPlan plan, MavenProject project, LifecycleBindingManager lifecycleBindingManager, boolean extendedInfo ) throws LifecycleSpecificationException, LifecyclePlannerException, LifecycleLoaderException { @@ -60,12 +69,10 @@ return listBuildPlan( mojoBindings, extendedInfo ); } - public static String listBuildPlan( List mojoBindings ) - throws LifecycleSpecificationException, LifecyclePlannerException - { - return listBuildPlan( mojoBindings, false ); - } - + /** + * Render a list containing the MojoBinding instances for an entire build plan to a String. + * If extendedInfo == true, include each MojoBinding's configuration in the output. + */ public static String listBuildPlan( List mojoBindings, boolean extendedInfo ) throws LifecycleSpecificationException, LifecyclePlannerException { @@ -127,6 +134,10 @@ return listing.toString(); } + /** + * Append a newline character, add the next line's number, and indent the new line to the + * appropriate level (which tracks separate forked executions). + */ private static void newListingLine( StringBuffer listing, int indentLevel, int counter ) { listing.append( '\n' ); @@ -143,11 +154,10 @@ } - public static String formatMojoListing( MojoBinding binding, int indentLevel ) - { - return formatMojoListing( binding, indentLevel, false ); - } - + /** + * Format a single MojoBinding for inclusion in a build plan listing. If extendedInfo == true, + * include the MojoBinding's configuration in the output. + */ public static String formatMojoListing( MojoBinding binding, int indentLevel, boolean extendedInfo ) { StringBuffer listing = new StringBuffer(); Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java Thu Mar 15 21:25:05 2007 @@ -6,9 +6,22 @@ import java.util.List; +/** + * Responsible for creating a plan of execution for a given project and list of tasks. This build plan + * consists of MojoBinding instances that carry all the information necessary to execute a mojo, + * including configuration from the POM and other sources. NOTE: the build plan may be constructed + * of a main lifecycle binding-set, plus any number of lifecycle modifiers and direct-invocation + * modifiers, to handle cases of forked execution. + * + * @author jdcasey + * + */ public interface BuildPlanner { - BuildPlan constructLifecyclePlan( List tasks, MavenProject project ) + /** + * Orchestrates construction of the build plan which will be used by the user of LifecycleExecutor. + */ + BuildPlan constructBuildPlan( List tasks, MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException; } Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java Thu Mar 15 21:25:05 2007 @@ -22,8 +22,16 @@ import java.util.LinkedList; import java.util.List; -// FIXME: The forkingBindings collections are misused; they will probably not prevent cyclic build -// processes consisting of > 1 elements. +/** + * Responsible for creating a plan of execution for a given project and list of tasks. This build plan + * consists of MojoBinding instances that carry all the information necessary to execute a mojo, + * including configuration from the POM and other sources. NOTE: the build plan may be constructed + * of a main lifecycle binding-set, plus any number of lifecycle modifiers and direct-invocation + * modifiers, to handle cases of forked execution. + * + * @author jdcasey + * + */ public class DefaultBuildPlanner implements BuildPlanner, LogEnabled { @@ -36,7 +44,10 @@ private MojoBindingFactory mojoBindingFactory; - public BuildPlan constructLifecyclePlan( List tasks, MavenProject project ) + /** + * Orchestrates construction of the build plan which will be used by the user of LifecycleExecutor. + */ + public BuildPlan constructBuildPlan( List tasks, MavenProject project ) throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException { LifecycleBindings defaultBindings = lifecycleBindingManager.getDefaultBindings( project ); @@ -67,6 +78,11 @@ this.logger = logger; } + /** + * Traverses all MojoBinding instances discovered from the POM and its packaging-mappings, and + * orchestrates the process of injecting any modifiers that are necessary to accommodate forked + * execution. + */ private void addForkedLifecycleModifiers( ModifiablePlanElement planElement, LifecycleBindings lifecycleBindings, MavenProject project, List tasks ) throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException @@ -98,6 +114,11 @@ } } + /** + * Traverses all MojoBinding instances discovered from the POM and its packaging-mappings, and + * orchestrates the process of injecting any modifiers that are necessary to accommodate mojos + * that require access to the project's configured reports. + */ private void addReportingLifecycleModifiers( ModifiablePlanElement planElement, LifecycleBindings lifecycleBindings, MavenProject project, List tasks ) throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException @@ -140,6 +161,10 @@ } } + /** + * Explores a single MojoBinding, and injects any necessary plan modifiers to accommodate any + * of the three types of forked execution, along with any new mojos/lifecycles that entails. + */ private void findForkModifiers( MojoBinding mojoBinding, PluginDescriptor pluginDescriptor, ModifiablePlanElement planElement, LifecycleBindings mergedBindings, MavenProject project, LinkedList forkingBindings, List tasks ) @@ -169,6 +194,10 @@ } } + /** + * Handles exploration of a single-mojo forked execution for further forkings, and also performs + * the actual build-plan modification for that single-mojo forked execution. + */ private void modifyBuildPlanForForkedDirectInvocation( MojoBinding invokedBinding, MojoBinding invokedVia, PluginDescriptor pluginDescriptor, ModifiablePlanElement planElement, LifecycleBindings mergedBindings, MavenProject project, @@ -208,6 +237,10 @@ } } + /** + * Handles exploration of a lifecycle-based forked execution for further forkings, and also performs + * the actual build-plan modification for that lifecycle-based forked execution. + */ private void modifyBuildPlanForForkedLifecycle( MojoBinding mojoBinding, PluginDescriptor pluginDescriptor, ModifiablePlanElement planElement, LifecycleBindings bindings, MavenProject project, LinkedList forkingBindings, List tasks ) @@ -272,6 +305,15 @@ } } + /** + * Constructs the lifecycle bindings used to execute a particular fork, given the forking mojo + * binding. If the mojo binding specifies a lifecycle overlay, this method will add that into + * the forked lifecycle, and calculate the bindings to inject based on the phase in that new + * lifecycle which should be executed. + * + * Hands off to the [EMAIL PROTECTED] DefaultBuildPlanner#modifyBuildPlanForForkedLifecycle(MojoBinding, PluginDescriptor, ModifiablePlanElement, LifecycleBindings, MavenProject, LinkedList, List)} + * method to handle the actual plan modification. + */ private void recursePhaseMojoFork( MojoBinding mojoBinding, PluginDescriptor pluginDescriptor, ModifiablePlanElement planElement, LifecycleBindings mergedBindings, MavenProject project, LinkedList forkingBindings, List tasks ) @@ -322,6 +364,11 @@ modifyBuildPlanForForkedLifecycle( mojoBinding, pluginDescriptor, planElement, cloned, project, forkingBindings, tasks ); } + /** + * Retrieves the information necessary to create a new MojoBinding for a single-mojo forked + * execution, then hands off to the [EMAIL PROTECTED] DefaultBuildPlanner#modifyBuildPlanForForkedDirectInvocation(MojoBinding, MojoBinding, PluginDescriptor, ModifiablePlanElement, LifecycleBindings, MavenProject, LinkedList, List)} + * method to actually inject the modification. + */ private void recurseSingleMojoFork( MojoBinding mojoBinding, PluginDescriptor pluginDescriptor, ModifiablePlanElement planElement, LifecycleBindings mergedBindings, MavenProject project, LinkedList forkingBindings, List tasks ) Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationModifier.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationModifier.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationModifier.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationModifier.java Thu Mar 15 21:25:05 2007 @@ -1,16 +1,32 @@ package org.apache.maven.lifecycle.plan; import org.apache.maven.lifecycle.binding.LifecycleBindingManager; +import org.apache.maven.lifecycle.model.LifecycleBindings; import org.apache.maven.lifecycle.model.MojoBinding; import org.apache.maven.project.MavenProject; import java.util.List; +/** + * Modifier that alters a build plan to substitute a set of MojoBindings in place of a single, + * direct-invocation MojoBinding. These bindings are not impacted by [EMAIL PROTECTED] BuildPlanModifier}s, + * since they don't exist in a [EMAIL PROTECTED] LifecycleBindings} instance. + * + * @author jdcasey + * + */ public interface DirectInvocationModifier { + /** + * The MojoBinding which should be modified. + */ MojoBinding getBindingToModify(); + /** + * Return the list of MojoBindings which should replace the modified binding in the master + * build plan. + */ List getModifiedBindings( MavenProject project, LifecycleBindingManager bindingManager ); } Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationOriginElement.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationOriginElement.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationOriginElement.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DirectInvocationOriginElement.java Thu Mar 15 21:25:05 2007 @@ -1,8 +1,17 @@ package org.apache.maven.lifecycle.plan; +/** + * Instantiates MojoBindings for direct invocation, which may be subject to modification. + * + * @author jdcasey + * + */ public interface DirectInvocationOriginElement { + /** + * Add a new direct-invocation binding modifier. + */ void addDirectInvocationModifier( DirectInvocationModifier modifier ); } Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkPlanModifier.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkPlanModifier.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkPlanModifier.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkPlanModifier.java Thu Mar 15 21:25:05 2007 @@ -10,6 +10,14 @@ import java.util.Iterator; import java.util.List; +/** + * Inject a list of forked-execution bindings at the point where the modification point is bound to + * the supplied LifecycleBindings, bracketed by special mojo bindings to control the forked-execution + * context. + * + * @author jdcasey + * + */ public class ForkPlanModifier implements BuildPlanModifier { @@ -25,11 +33,19 @@ this.mojoBindings = mojoBindings; } + /** + * Retrieve the MojoBinding which serves as the injection point for the forked bindings. + */ public MojoBinding getModificationPoint() { return modificationPoint; } + /** + * Modify the LifeycleBindings from a BuildPlan by locating the modification point MojoBinding, + * and prepending the forked-execution bindings in the plan, bracketed by mojos that control the + * forked-execution context. + */ public LifecycleBindings modifyBindings( LifecycleBindings bindings ) throws LifecyclePlannerException { @@ -78,11 +94,17 @@ return bindings; } + /** + * Add a new modifier to further adjust the LifecycleBindings which are modified here. + */ public void addModifier( BuildPlanModifier planModifier ) { planModifiers.add( planModifier ); } + /** + * Return true if this modifier itself has modifiers. + */ public boolean hasModifiers() { return !planModifiers.isEmpty(); Modified: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkedDirectInvocationModifier.java URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkedDirectInvocationModifier.java?view=diff&rev=518859&r1=518858&r2=518859 ============================================================================== --- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkedDirectInvocationModifier.java (original) +++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/main/java/org/apache/maven/lifecycle/plan/ForkedDirectInvocationModifier.java Thu Mar 15 21:25:05 2007 @@ -8,6 +8,13 @@ import java.util.ArrayList; import java.util.List; +/** + * Inject a list of MojoBindings in place of the forking binding, bracketing the forked bindings with + * special mojos to control the forked-execution context. + * + * @author jdcasey + * + */ public class ForkedDirectInvocationModifier implements DirectInvocationModifier { @@ -21,6 +28,10 @@ this.forkedBindings = forkedBindings; } + /** + * Return a list containing forked-execution context control MojoBindings, the forked-execution + * bindings themselves, and finally the binding that forked off a new execution branch. + */ public List getModifiedBindings( MavenProject project, LifecycleBindingManager bindingManager ) { List result = new ArrayList(); @@ -34,6 +45,9 @@ return result; } + /** + * Return the MojoBinding that forks execution to include the bindings in this modifier. + */ public MojoBinding getBindingToModify() { return forkingBinding; Added: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-class-diagram.png URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-class-diagram.png?view=auto&rev=518859 ============================================================================== Binary file - no diff available. Propchange: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-class-diagram.png ------------------------------------------------------------------------------ svn:executable = * Propchange: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-class-diagram.png ------------------------------------------------------------------------------ svn:mime-type = image/png Added: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-sequence-diagram.png URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-sequence-diagram.png?view=auto&rev=518859 ============================================================================== Binary file - no diff available. Propchange: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-sequence-diagram.png ------------------------------------------------------------------------------ svn:executable = * Propchange: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/site/resources/design/2.1-lifecycle-refactor-sequence-diagram.png ------------------------------------------------------------------------------ svn:mime-type = image/png