mirror of https://github.com/apache/maven.git
Fixing plugin manager/plugin version manager for use with the help plugin...restoring backward compat.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@536027 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
11a113d316
commit
44c006ff2a
|
@ -94,6 +94,14 @@ public class DefaultBuildPlanner
|
|||
{
|
||||
MojoBinding mojoBinding = (MojoBinding) it.next();
|
||||
|
||||
findForkModifiers( mojoBinding, planElement, lifecycleBindings, project );
|
||||
}
|
||||
}
|
||||
|
||||
private void findForkModifiers( MojoBinding mojoBinding, ModifiablePlanElement planElement,
|
||||
LifecycleBindings lifecycleBindings, MavenProject project )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor;
|
||||
try
|
||||
{
|
||||
|
@ -111,8 +119,7 @@ public class DefaultBuildPlanner
|
|||
+ pluginDescriptor.getId() + "." );
|
||||
}
|
||||
|
||||
findForkModifiers( mojoBinding, pluginDescriptor, planElement, lifecycleBindings, project, new LinkedList(), tasks );
|
||||
}
|
||||
findForkModifiers( mojoBinding, pluginDescriptor, planElement, lifecycleBindings, project, new LinkedList() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,6 +158,26 @@ public class DefaultBuildPlanner
|
|||
{
|
||||
List reportBindings = lifecycleBindingManager.getReportBindings( project );
|
||||
|
||||
// findForkModifiers( mojoBinding, pluginDescriptor, planElement, lifecycleBindings,
|
||||
// project, forkingBindings, tasks );
|
||||
for ( Iterator reportBindingIt = reportBindings.iterator(); reportBindingIt.hasNext(); )
|
||||
{
|
||||
MojoBinding reportBinding = (MojoBinding) reportBindingIt.next();
|
||||
|
||||
PluginDescriptor pd;
|
||||
try
|
||||
{
|
||||
pd = pluginLoader.loadReportPlugin( mojoBinding, project );
|
||||
}
|
||||
catch ( PluginLoaderException e )
|
||||
{
|
||||
throw new LifecyclePlannerException( "Failed to load report-plugin descriptor for: "
|
||||
+ MojoBindingUtils.toString( reportBinding ) + ". Reason: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
// findForkModifiers( reportBinding, planElement, lifecycleBindings, project );
|
||||
}
|
||||
|
||||
Phase phase = LifecycleUtils.findPhaseForMojoBinding( mojoBinding, lifecycleBindings, true );
|
||||
|
||||
if ( phase == null )
|
||||
|
@ -188,7 +215,7 @@ public class DefaultBuildPlanner
|
|||
*/
|
||||
private void findForkModifiers( MojoBinding mojoBinding, PluginDescriptor pluginDescriptor,
|
||||
ModifiablePlanElement planElement, LifecycleBindings mergedBindings, MavenProject project,
|
||||
LinkedList forkingBindings, List tasks )
|
||||
LinkedList forkingBindings )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
forkingBindings.addLast( mojoBinding );
|
||||
|
@ -201,12 +228,11 @@ public class DefaultBuildPlanner
|
|||
|
||||
if ( mojoDescriptor.getExecuteGoal() != null )
|
||||
{
|
||||
recurseSingleMojoFork( mojoBinding, pluginDescriptor, planElement, mergedBindings, project, forkingBindings,
|
||||
tasks );
|
||||
recurseSingleMojoFork( mojoBinding, pluginDescriptor, planElement, mergedBindings, project, forkingBindings );
|
||||
}
|
||||
else if ( mojoDescriptor.getExecutePhase() != null )
|
||||
{
|
||||
recursePhaseMojoFork( mojoBinding, pluginDescriptor, planElement, mergedBindings, project, forkingBindings, tasks );
|
||||
recursePhaseMojoFork( mojoBinding, pluginDescriptor, planElement, mergedBindings, project, forkingBindings );
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@ -222,7 +248,7 @@ public class DefaultBuildPlanner
|
|||
private void modifyBuildPlanForForkedDirectInvocation( MojoBinding invokedBinding, MojoBinding invokedVia,
|
||||
PluginDescriptor pluginDescriptor, ModifiablePlanElement planElement,
|
||||
LifecycleBindings mergedBindings, MavenProject project,
|
||||
LinkedList forkingBindings, List tasks )
|
||||
LinkedList forkingBindings )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
if ( planElement instanceof DirectInvocationOriginElement )
|
||||
|
@ -235,8 +261,7 @@ public class DefaultBuildPlanner
|
|||
forkingBindings.addLast( invokedBinding );
|
||||
try
|
||||
{
|
||||
findForkModifiers( invokedBinding, pluginDescriptor, forkedPlan, forkedBindings, project,
|
||||
forkingBindings, tasks );
|
||||
findForkModifiers( invokedBinding, pluginDescriptor, forkedPlan, forkedBindings, project, forkingBindings );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -264,7 +289,7 @@ public class DefaultBuildPlanner
|
|||
*/
|
||||
private void modifyBuildPlanForForkedLifecycle( MojoBinding mojoBinding, PluginDescriptor pluginDescriptor,
|
||||
ModifiablePlanElement planElement, LifecycleBindings bindings,
|
||||
MavenProject project, LinkedList forkingBindings, List tasks )
|
||||
MavenProject project, LinkedList forkingBindings )
|
||||
throws LifecycleSpecificationException, LifecyclePlannerException, LifecycleLoaderException
|
||||
{
|
||||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoBinding.getGoal() );
|
||||
|
@ -307,7 +332,7 @@ public class DefaultBuildPlanner
|
|||
throw new LifecyclePlannerException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
findForkModifiers( forkedBinding, forkedPluginDescriptor, mpe, bindings, project, forkingBindings, tasks );
|
||||
findForkModifiers( forkedBinding, forkedPluginDescriptor, mpe, bindings, project, forkingBindings );
|
||||
}
|
||||
|
||||
// now that we've discovered any deeper modifications, add the current MPE to the parent MPE
|
||||
|
@ -337,7 +362,7 @@ public class DefaultBuildPlanner
|
|||
*/
|
||||
private void recursePhaseMojoFork( MojoBinding mojoBinding, PluginDescriptor pluginDescriptor,
|
||||
ModifiablePlanElement planElement, LifecycleBindings mergedBindings, MavenProject project,
|
||||
LinkedList forkingBindings, List tasks )
|
||||
LinkedList forkingBindings )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
String referencingGoal = mojoBinding.getGoal();
|
||||
|
@ -382,7 +407,7 @@ public class DefaultBuildPlanner
|
|||
|
||||
LifecycleUtils.removeMojoBindings( forkingBindings, cloned, false );
|
||||
|
||||
modifyBuildPlanForForkedLifecycle( mojoBinding, pluginDescriptor, planElement, cloned, project, forkingBindings, tasks );
|
||||
modifyBuildPlanForForkedLifecycle( mojoBinding, pluginDescriptor, planElement, cloned, project, forkingBindings );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,7 +417,7 @@ public class DefaultBuildPlanner
|
|||
*/
|
||||
private void recurseSingleMojoFork( MojoBinding mojoBinding, PluginDescriptor pluginDescriptor,
|
||||
ModifiablePlanElement planElement, LifecycleBindings mergedBindings,
|
||||
MavenProject project, LinkedList forkingBindings, List tasks )
|
||||
MavenProject project, LinkedList forkingBindings )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
String referencingGoal = mojoBinding.getGoal();
|
||||
|
@ -422,7 +447,7 @@ public class DefaultBuildPlanner
|
|||
if ( !LifecycleUtils.isMojoBindingPresent( binding, forkingBindings, false ) )
|
||||
{
|
||||
modifyBuildPlanForForkedDirectInvocation( binding, mojoBinding, pluginDescriptor, planElement, mergedBindings,
|
||||
project, forkingBindings, tasks );
|
||||
project, forkingBindings );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
|||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.reporting.MavenReport;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
|
@ -162,6 +163,28 @@ public class DefaultPluginManager
|
|||
session.getLocalRepository() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
|
||||
PluginVersionNotFoundException
|
||||
{
|
||||
// TODO: this should be possibly outside
|
||||
// All version-resolution logic has been moved to DefaultPluginVersionManager.
|
||||
if ( plugin.getVersion() == null )
|
||||
{
|
||||
getLogger().debug( "Resolving version for plugin: " + plugin.getKey() );
|
||||
String version = pluginVersionManager.resolvePluginVersion( plugin.getGroupId(), plugin.getArtifactId(),
|
||||
project, localRepository );
|
||||
plugin.setVersion( version );
|
||||
}
|
||||
|
||||
return verifyVersionedPlugin( plugin, project, localRepository );
|
||||
}
|
||||
|
||||
public PluginDescriptor verifyPlugin( Plugin plugin,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.plugin;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
|
@ -31,6 +32,7 @@ import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.reporting.MavenReport;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -61,6 +63,17 @@ public interface PluginManager
|
|||
MavenSession session,
|
||||
MavenProject project );
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
PluginDescriptor verifyPlugin( Plugin plugin,
|
||||
MavenProject project,
|
||||
Settings settings,
|
||||
ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
|
||||
PluginVersionNotFoundException;
|
||||
|
||||
PluginDescriptor verifyPlugin( Plugin plugin,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
|
|
|
@ -61,13 +61,22 @@ public class DefaultPluginVersionManager
|
|||
// TODO: Revisit to remove this piece of state. PLUGIN REGISTRY MAY BE UPDATED ON DISK OUT-OF-PROCESS!
|
||||
private Map resolvedMetaVersions = new HashMap();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, ArtifactRepository localRepository )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
return resolvePluginVersion( groupId, artifactId, project, localRepository, false );
|
||||
}
|
||||
|
||||
public String resolvePluginVersion( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
return resolvePluginVersion( groupId, artifactId, project, session, false );
|
||||
return resolvePluginVersion( groupId, artifactId, project, session.getLocalRepository(), false );
|
||||
}
|
||||
|
||||
public String resolveReportPluginVersion( String groupId,
|
||||
|
@ -76,18 +85,16 @@ public class DefaultPluginVersionManager
|
|||
MavenSession session )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
return resolvePluginVersion( groupId, artifactId, project, session, true );
|
||||
return resolvePluginVersion( groupId, artifactId, project, session.getLocalRepository(), true );
|
||||
}
|
||||
|
||||
private String resolvePluginVersion( String groupId,
|
||||
String artifactId,
|
||||
MavenProject project,
|
||||
MavenSession session,
|
||||
ArtifactRepository localRepository,
|
||||
boolean resolveAsReportPlugin )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
ArtifactRepository localRepository = session.getLocalRepository();
|
||||
|
||||
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
||||
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
|
||||
getLogger().debug( "Version from POM: " + version );
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.plugin.version;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.InvalidPluginException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
@ -27,6 +28,12 @@ public interface PluginVersionManager
|
|||
{
|
||||
String ROLE = PluginVersionManager.class.getName();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
String resolvePluginVersion( String groupId, String artifactId, MavenProject project, ArtifactRepository localRepository )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
|
||||
|
||||
String resolvePluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
|
||||
|
||||
|
|
Loading…
Reference in New Issue