mirror of https://github.com/apache/maven.git
o remove duplicate signature from the plugin manager
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@751492 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
600dab7b1d
commit
9a2c66dde1
|
@ -1266,7 +1266,7 @@ public class DefaultLifecycleExecutor
|
|||
String prefix = tok.nextToken();
|
||||
goal = tok.nextToken();
|
||||
|
||||
plugin = pluginManager.getPluginDefinitionForPrefix( prefix, session, project );
|
||||
plugin = pluginManager.findPluginForPrefix( prefix, project, session );
|
||||
|
||||
if ( plugin == null )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -26,11 +26,10 @@ import org.apache.maven.monitor.event.EventDispatcher;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@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 )
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.List;
|
|||
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 class DefaultPluginManager
|
|||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
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 @@ public class DefaultPluginManager
|
|||
{
|
||||
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 @@ public class DefaultPluginManager
|
|||
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
|
||||
{
|
||||
|
|
|
@ -27,24 +27,34 @@ import org.apache.maven.reporting.MavenReport;
|
|||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface PluginManager
|
||||
{
|
||||
void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
|
||||
throws ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException, InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException;
|
||||
|
||||
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;
|
||||
|
||||
// - 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;
|
||||
|
||||
PluginDescriptor loadReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
||||
throws PluginLoaderException;
|
||||
}
|
Loading…
Reference in New Issue