Author: jvanzyl Date: Sun Mar 8 18:22:23 2009 New Revision: 751492 URL: http://svn.apache.org/viewvc?rev=751492&view=rev Log: o remove duplicate signature from the plugin manager
Added: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java (with props) Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=751492&r1=751491&r2=751492&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Sun Mar 8 18:22:23 2009 @@ -1266,7 +1266,7 @@ String prefix = tok.nextToken(); goal = tok.nextToken(); - plugin = pluginManager.getPluginDefinitionForPrefix( prefix, session, project ); + plugin = pluginManager.findPluginForPrefix( prefix, project, session ); if ( plugin == null ) { Added: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java?rev=751492&view=auto ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java (added) +++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java Sun Mar 8 18:22:23 2009 @@ -0,0 +1,101 @@ +package org.apache.maven.lifecycle; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Class Lifecycle. + */ +public class Lifecycle +{ + /** + * Field id + */ + private String id; + + /** + * Field phases + */ + private List phases; + + /** + * default phases. + */ + private Map defaultPhases; + + /** + * Method addPhase + * + * @param phase + */ + public void addPhase( String phase ) + { + getPhases().add( phase ); + } //-- void addPhase(Phase) + + /** + * Method getId + */ + public String getId() + { + return this.id; + } //-- String getId() + + /** + * Method getPhases + */ + public List getPhases() + { + if ( this.phases == null ) + { + this.phases = new ArrayList(); + } + + return this.phases; + } //-- java.util.List getPhases() + + /** + * Method setId + * + * @param id + */ + public void setId( String id ) + { + this.id = id; + } //-- void setId(String) + + /** + * Method setPhases + * + * @param phases + */ + public void setPhases( List phases ) + { + this.phases = phases; + } //-- void setPhases(java.util.List) + + public Map getDefaultPhases() + { + return defaultPhases; + } +} Propchange: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java?rev=751492&r1=751491&r2=751492&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java Sun Mar 8 18:22:23 2009 @@ -26,11 +26,10 @@ import org.apache.maven.project.MavenProject; /** - * @author <a href="mailto:ja...@maven.org">Jason van Zyl</a> - * @version $Id$ + * @author Jason van Zyl */ public interface LifecycleExecutor -{ +{ TaskValidationResult isTaskValid( String task, MavenSession session, MavenProject rootProject ); void execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher ) Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=751492&r1=751491&r2=751492&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Sun Mar 8 18:22:23 2009 @@ -29,7 +29,6 @@ import java.util.Map; import java.util.Set; -import org.apache.commons.jxpath.JXPathContext; import org.apache.maven.ArtifactFilterManager; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; @@ -151,7 +150,7 @@ // // ---------------------------------------------------------------------- - public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project ) + public Plugin findPluginForPrefix( String prefix, MavenProject project, MavenSession session ) { // TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other // use for the mapping manager in here @@ -184,8 +183,6 @@ { logger.debug( "In verifyVersionedPlugin for: " + plugin.getKey() ); - ArtifactRepository localRepository = session.getLocalRepository(); - // TODO: this might result in an artifact "RELEASE" being resolved continuously // FIXME: need to find out how a plugin gets marked as 'installed' // and no ChildContainer exists. The check for that below fixes @@ -1523,137 +1520,6 @@ return ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri ); } - // Plugin Prefix Loader - - /** - * Determine the appropriate {...@link PluginDescriptor} instance for use with the specified plugin - * prefix, using the following strategies (in order): <br/> - * <ol> - * <li>Search for a plugin that has already been loaded with the specified prefix</li> - * <li>Search for a plugin configured in the POM that has a matching prefix</li> - * <li>Search the pluginGroups specified in the settings.xml for a matching plugin</li> - * <li>Use groupId == org.apache.maven.plugins, and artifactId == maven-<prefix>-plugin, - * and try to resolve based on that.</li> - * </ol> - */ - public Plugin findPluginForPrefix( String prefix, MavenProject project, MavenSession session ) - throws PluginLoaderException - { - Set descriptors = pluginCollector.getPluginDescriptorsForPrefix( prefix ); - Map projectPluginMap = project.getBuild().getPluginsAsMap(); - - Plugin plugin = null; - - if ( descriptors != null ) - { - PluginDescriptor pluginDescriptor = null; - - for ( Iterator it = descriptors.iterator(); it.hasNext(); ) - { - PluginDescriptor pd = (PluginDescriptor) it.next(); - - Plugin projectPlugin = (Plugin) projectPluginMap.get( pd.getPluginLookupKey() ); - if ( ( projectPlugin != null ) && ( projectPlugin.getVersion() != null ) && projectPlugin.getVersion().equals( pd.getVersion() ) ) - { - pluginDescriptor = pd; - break; - } - } - - plugin = toPlugin( pluginDescriptor ); - } - - if ( plugin == null ) - { - PluginDescriptor pluginDescriptor = loadFromProjectForPrefixQuery( prefix, project, session ); - - plugin = toPlugin( pluginDescriptor ); - } - - if ( plugin == null ) - { - plugin = loadFromPrefixMapper( prefix, project, session ); - } - - if ( plugin == null ) - { - plugin = new Plugin(); - plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) ); - - PluginDescriptor pluginDescriptor = loadIsolatedPluginDescriptor( plugin, project, session ); - plugin = toPlugin( pluginDescriptor ); - } - - if ( plugin == null ) - { - throw new PluginLoaderException( "Cannot find plugin with prefix: " + prefix ); - } - - return plugin; - } - - private Plugin toPlugin( PluginDescriptor pluginDescriptor ) - { - if ( pluginDescriptor == null ) - { - return null; - } - - Plugin plugin = new Plugin(); - - plugin.setGroupId( pluginDescriptor.getGroupId() ); - plugin.setArtifactId( pluginDescriptor.getArtifactId() ); - plugin.setVersion( pluginDescriptor.getVersion() ); - - return plugin; - } - - /** - * Look for a plugin configured in the current project that has a prefix matching the one - * specified. Return the {...@link PluginDescriptor} if a match is found. - */ - private PluginDescriptor loadFromProjectForPrefixQuery( String prefix, MavenProject project, MavenSession session ) - throws PluginLoaderException - { - PluginDescriptor result = null; - - for ( Iterator it = project.getBuildPlugins().iterator(); it.hasNext(); ) - { - Plugin plugin = (Plugin) it.next(); - - PluginDescriptor pluginDescriptor = loadIsolatedPluginDescriptor( plugin, project, session ); - - if ( ( pluginDescriptor != null ) && prefix.equals( pluginDescriptor.getGoalPrefix() ) ) - { - result = pluginDescriptor; - break; - } - } - - return result; - } - - /** - * Look for a plugin in the pluginGroups specified in the settings.xml that has a prefix - * matching the one specified. Return the {...@link PluginDescriptor} if a match is found. - */ - private Plugin loadFromPrefixMapper( String prefix, MavenProject project, MavenSession session ) - throws PluginLoaderException - { - Plugin plugin = getByPrefix( prefix, session.getPluginGroups(), project.getRemoteArtifactRepositories(), session.getLocalRepository() ); - - if ( plugin != null ) - { - Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey() ); - if ( ( projectPlugin != null ) && ( projectPlugin.getVersion() != null ) ) - { - plugin.setVersion( projectPlugin.getVersion() ); - } - } - - return plugin; - } - public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session ) throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException { Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?rev=751492&r1=751491&r2=751492&view=diff ============================================================================== --- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java (original) +++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java Sun Mar 8 18:22:23 2009 @@ -27,24 +27,34 @@ /** * @author Jason van Zyl - * @version $Id$ */ public interface PluginManager { + // - find the plugin [extension point: any client may wish to do whatever they choose] + // - load the plugin [extension point: we want to take them from a repository, some may take from disk or whatever] + // - configure the plugin + // - execute the plugin + + Plugin findPluginForPrefix( String prefix, MavenProject project, MavenSession session ); + + PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session ) + throws PluginLoaderException; + + //!!jvz + // Clean up the exceptions returned. We should not be coupled to the repository layer. We need to generalize to allow a general plugin mechanism. void executeMojo( MavenProject project, MojoExecution execution, MavenSession session ) throws ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException, InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException; - + + //!!jvz + // Reporting + // As a function inside Maven is wrong. This needs to be entirely delegated to an external system. We need to provide an extension + // point for any tools that want to hook into the lifecycle but burning reporting into the core is extremely bad coupling. We need + // an aliasing mechanism for the POM as not to break backward compat. During 3.0 we can support this and at 3.1 with changes to the + // model we turf it. + MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session ) throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException, ArtifactResolutionException; - - Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project ); - - Plugin findPluginForPrefix( String prefix, MavenProject project, MavenSession session ) - throws PluginLoaderException; - - PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session ) - throws PluginLoaderException; - + PluginDescriptor loadReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session ) throws PluginLoaderException; } \ No newline at end of file