mirror of https://github.com/apache/maven.git
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@750351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3efeef0d89
commit
3a2b747af0
|
@ -42,13 +42,16 @@ import org.apache.maven.repository.MavenRepositorySystem;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
@Component(role = PluginVersionManager.class)
|
@Component(role = PluginVersionManager.class)
|
||||||
public class DefaultPluginVersionManager
|
public class DefaultPluginVersionManager
|
||||||
extends AbstractLogEnabled
|
|
||||||
implements PluginVersionManager
|
implements PluginVersionManager
|
||||||
{
|
{
|
||||||
|
@Requirement
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
@Requirement
|
@Requirement
|
||||||
private MavenRepositorySystem repositoryTools;
|
private MavenRepositorySystem repositoryTools;
|
||||||
|
|
||||||
|
@ -76,7 +79,7 @@ public class DefaultPluginVersionManager
|
||||||
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
||||||
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
|
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
|
||||||
|
|
||||||
getLogger().debug( "Version from POM: " + version );
|
logger.debug( "Version from POM: " + version );
|
||||||
|
|
||||||
// NOTE: We CANNOT check the current project version here, so delay it until later.
|
// NOTE: We CANNOT check the current project version here, so delay it until later.
|
||||||
// It will prevent plugins from building themselves, if they are part of the lifecycle mapping.
|
// It will prevent plugins from building themselves, if they are part of the lifecycle mapping.
|
||||||
|
@ -94,7 +97,7 @@ public class DefaultPluginVersionManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getLogger().debug( "Version from another POM in the reactor: " + version );
|
logger.debug( "Version from another POM in the reactor: " + version );
|
||||||
|
|
||||||
// third pass...we're always checking for latest install/deploy, so retrieve the version for LATEST metadata and
|
// third pass...we're always checking for latest install/deploy, so retrieve the version for LATEST metadata and
|
||||||
// also set that resolved version as the <useVersion/> in settings.xml.
|
// also set that resolved version as the <useVersion/> in settings.xml.
|
||||||
|
@ -102,7 +105,7 @@ public class DefaultPluginVersionManager
|
||||||
{
|
{
|
||||||
// 1. resolve the version to be used
|
// 1. resolve the version to be used
|
||||||
version = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.LATEST_VERSION );
|
version = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.LATEST_VERSION );
|
||||||
getLogger().debug( "Version from LATEST metadata: " + version );
|
logger.debug( "Version from LATEST metadata: " + version );
|
||||||
}
|
}
|
||||||
|
|
||||||
// final pass...retrieve the version for RELEASE and also set that resolved version as the <useVersion/>
|
// final pass...retrieve the version for RELEASE and also set that resolved version as the <useVersion/>
|
||||||
|
@ -111,7 +114,7 @@ public class DefaultPluginVersionManager
|
||||||
{
|
{
|
||||||
// 1. resolve the version to be used
|
// 1. resolve the version to be used
|
||||||
version = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.RELEASE_VERSION );
|
version = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.RELEASE_VERSION );
|
||||||
getLogger().debug( "Version from RELEASE metadata: " + version );
|
logger.debug( "Version from RELEASE metadata: " + version );
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we still haven't found a version, then fail early before we get into the update goop.
|
// if we still haven't found a version, then fail early before we get into the update goop.
|
||||||
|
@ -164,14 +167,10 @@ public class DefaultPluginVersionManager
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveMetaVersion( String groupId,
|
private String resolveMetaVersion( String groupId, String artifactId, MavenProject project, ArtifactRepository localRepository, String metaVersionId )
|
||||||
String artifactId,
|
|
||||||
MavenProject project,
|
|
||||||
ArtifactRepository localRepository,
|
|
||||||
String metaVersionId )
|
|
||||||
throws PluginVersionResolutionException, InvalidPluginException
|
throws PluginVersionResolutionException, InvalidPluginException
|
||||||
{
|
{
|
||||||
getLogger().info( "Attempting to resolve a version for plugin: " + groupId + ":" + artifactId + " using meta-version: " + metaVersionId );
|
logger.info( "Attempting to resolve a version for plugin: " + groupId + ":" + artifactId + " using meta-version: " + metaVersionId );
|
||||||
|
|
||||||
Artifact artifact = repositoryTools.createProjectArtifact( groupId, artifactId, metaVersionId );
|
Artifact artifact = repositoryTools.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||||
|
|
||||||
|
@ -182,8 +181,7 @@ public class DefaultPluginVersionManager
|
||||||
// This takes the spec version and resolves a real version
|
// This takes the spec version and resolves a real version
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ResolutionGroup resolutionGroup =
|
ResolutionGroup resolutionGroup = repositoryTools.retrieve( artifact, localRepository, project.getRemoteArtifactRepositories() );
|
||||||
repositoryTools.retrieve( artifact, localRepository, project.getRemoteArtifactRepositories() );
|
|
||||||
|
|
||||||
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
|
// switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom
|
||||||
// artifact.
|
// artifact.
|
||||||
|
@ -232,7 +230,7 @@ public class DefaultPluginVersionManager
|
||||||
{
|
{
|
||||||
String range = "[" + mavenVersion + ",]";
|
String range = "[" + mavenVersion + ",]";
|
||||||
|
|
||||||
getLogger().debug( "Plugin: "
|
logger.debug( "Plugin: "
|
||||||
+ pluginProject.getId()
|
+ pluginProject.getId()
|
||||||
+ " specifies a simple prerequisite Maven version of: "
|
+ " specifies a simple prerequisite Maven version of: "
|
||||||
+ mavenVersion
|
+ mavenVersion
|
||||||
|
@ -244,14 +242,12 @@ public class DefaultPluginVersionManager
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Invalid prerequisite Maven version: " + mavenVersion + " for plugin: " + pluginProject.getId() +
|
logger.debug( "Invalid prerequisite Maven version: " + mavenVersion + " for plugin: " + pluginProject.getId() + e.getMessage() );
|
||||||
e.getMessage() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( mavenRange != null ) && !mavenRange.containsVersion( runtimeInformation.getApplicationInformation().getVersion() ) )
|
if ( ( mavenRange != null ) && !mavenRange.containsVersion( runtimeInformation.getApplicationInformation().getVersion() ) )
|
||||||
{
|
{
|
||||||
getLogger().info( "Ignoring available plugin version: " + artifactVersion +
|
logger.info( "Ignoring available plugin version: " + artifactVersion + " for: " + groupId + ":" + artifactId + " as it requires Maven version matching: " + mavenVersion );
|
||||||
" for: " + groupId + ":" + artifactId + " as it requires Maven version matching: " + mavenVersion );
|
|
||||||
|
|
||||||
VersionRange vr;
|
VersionRange vr;
|
||||||
try
|
try
|
||||||
|
@ -260,29 +256,25 @@ public class DefaultPluginVersionManager
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
{
|
{
|
||||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
throw new PluginVersionResolutionException( groupId, artifactId, "Error getting available plugin versions: " + e.getMessage(), e );
|
||||||
"Error getting available plugin versions: " +
|
|
||||||
e.getMessage(), e );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().debug( "Trying " + vr );
|
logger.debug( "Trying " + vr );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List versions = repositoryTools.retrieveAvailableVersions( artifact, localRepository,
|
List versions = repositoryTools.retrieveAvailableVersions( artifact, localRepository, project.getRemoteArtifactRepositories() );
|
||||||
project.getRemoteArtifactRepositories() );
|
|
||||||
ArtifactVersion v = vr.matchVersion( versions );
|
ArtifactVersion v = vr.matchVersion( versions );
|
||||||
artifactVersion = v != null ? v.toString() : null;
|
artifactVersion = v != null ? v.toString() : null;
|
||||||
}
|
}
|
||||||
catch ( ArtifactMetadataRetrievalException e )
|
catch ( ArtifactMetadataRetrievalException e )
|
||||||
{
|
{
|
||||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
throw new PluginVersionResolutionException( groupId, artifactId, "Error getting available plugin versions: " + e.getMessage(), e );
|
||||||
"Error getting available plugin versions: " +
|
|
||||||
e.getMessage(), e );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( artifactVersion != null )
|
if ( artifactVersion != null )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Found " + artifactVersion );
|
logger.debug( "Found " + artifactVersion );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -294,11 +286,13 @@ public class DefaultPluginVersionManager
|
||||||
|
|
||||||
version = artifactVersion;
|
version = artifactVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( version == null )
|
if( version == null )
|
||||||
{
|
{
|
||||||
version = artifactVersion;
|
version = artifactVersion;
|
||||||
}
|
}
|
||||||
getLogger().info( "Using version: " + version + " of plugin: " + groupId + ":" + artifactId );
|
|
||||||
|
logger.info( "Using version: " + version + " of plugin: " + groupId + ":" + artifactId );
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue