git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@314802 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-12 06:35:11 +00:00
parent 2de21910eb
commit 0497cc28e7
1 changed files with 24 additions and 36 deletions

View File

@ -93,33 +93,21 @@ 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 );
// NOTE: [jc; 11-Oct-2005] We CANNOT have this type of code in here. It will prevent plugins from building themselves, // NOTE: We CANNOT check the current project version here, so delay it until later.
// if they are part of the lifecycle mapping. For example, try the following: // It will prevent plugins from building themselves, if they are part of the lifecycle mapping.
//
// 1. Uncomment the remainder of the following code block and rebuild the core jar; put it in the m2 distro
// 2. rm -Rf <local-repo>/org/apache/maven/plugins/maven-surefire-plugin
// 3. go to <maven>/maven-plugins/maven-surefire-plugin, and try to build it.
//
// In the above example, the surefire plugin fails to build because the version used for testing is
// resolved to the version currently being built...which obviously doesn't exist yet.
// if there was no explicit version, try for one in the reactor // if there was no explicit version, try for one in the reactor
if ( version == null ) if ( version == null )
{ {
// check self if ( project.getProjectReferences() != null )
// if ( project.getGroupId().equals( groupId ) && project.getArtifactId().equals( artifactId ) ) {
// {
// version = project.getVersion();
// }
// else if ( project.getProjectReferences() != null )
// {
String refId = ArtifactUtils.versionlessKey( groupId, artifactId ); String refId = ArtifactUtils.versionlessKey( groupId, artifactId );
MavenProject ref = (MavenProject) project.getProjectReferences().get( refId ); MavenProject ref = (MavenProject) project.getProjectReferences().get( refId );
if ( ref != null ) if ( ref != null )
{ {
version = ref.getVersion(); version = ref.getVersion();
} }
// } }
} }
// we're NEVER going to persist POM-derived plugin versions. // we're NEVER going to persist POM-derived plugin versions.
@ -151,8 +139,8 @@ public class DefaultPluginVersionManager
if ( Boolean.TRUE.equals( pluginUpdateOverride ) || if ( Boolean.TRUE.equals( pluginUpdateOverride ) ||
( !Boolean.FALSE.equals( pluginUpdateOverride ) && shouldCheckForUpdates( groupId, artifactId ) ) ) ( !Boolean.FALSE.equals( pluginUpdateOverride ) && shouldCheckForUpdates( groupId, artifactId ) ) )
{ {
updatedVersion = resolveMetaVersion( groupId, artifactId, project, localRepository, updatedVersion =
Artifact.LATEST_VERSION ); resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.LATEST_VERSION );
if ( StringUtils.isNotEmpty( updatedVersion ) && !updatedVersion.equals( version ) ) if ( StringUtils.isNotEmpty( updatedVersion ) && !updatedVersion.equals( version ) )
{ {
@ -217,7 +205,8 @@ public class DefaultPluginVersionManager
// if we're still empty here, and the current project matches the plugin in question, use the current project's // if we're still empty here, and the current project matches the plugin in question, use the current project's
// version, I guess... // version, I guess...
if ( StringUtils.isEmpty( version ) && project.getGroupId().equals( groupId ) && project.getArtifactId().equals( artifactId ) ) if ( StringUtils.isEmpty( version ) && project.getGroupId().equals( groupId ) &&
project.getArtifactId().equals( artifactId ) )
{ {
version = project.getVersion(); version = project.getVersion();
} }
@ -275,8 +264,8 @@ public class DefaultPluginVersionManager
// //
// NOTE: We're incorporating here, to make the usages of this check more consistent and // NOTE: We're incorporating here, to make the usages of this check more consistent and
// resistant to change. // resistant to change.
promptToPersist = promptToPersist && pluginUpdateOverride == null && applyToAll == null && promptToPersist =
inInteractiveMode; promptToPersist && pluginUpdateOverride == null && applyToAll == null && inInteractiveMode;
if ( promptToPersist ) if ( promptToPersist )
{ {
@ -327,8 +316,8 @@ public class DefaultPluginVersionManager
} }
else else
{ {
SimpleDateFormat format = new SimpleDateFormat( SimpleDateFormat format =
org.apache.maven.plugin.registry.Plugin.LAST_CHECKED_DATE_FORMAT ); new SimpleDateFormat( org.apache.maven.plugin.registry.Plugin.LAST_CHECKED_DATE_FORMAT );
try try
{ {
@ -569,8 +558,8 @@ public class DefaultPluginVersionManager
{ {
plugin.setUseVersion( version ); plugin.setUseVersion( version );
SimpleDateFormat format = new SimpleDateFormat( SimpleDateFormat format =
org.apache.maven.plugin.registry.Plugin.LAST_CHECKED_DATE_FORMAT ); new SimpleDateFormat( org.apache.maven.plugin.registry.Plugin.LAST_CHECKED_DATE_FORMAT );
plugin.setLastChecked( format.format( new Date() ) ); plugin.setLastChecked( format.format( new Date() ) );
} }
@ -661,8 +650,8 @@ public class DefaultPluginVersionManager
try try
{ {
ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository, ResolutionGroup resolutionGroup =
project.getPluginArtifactRepositories() ); artifactMetadataSource.retrieve( artifact, localRepository, project.getPluginArtifactRepositories() );
// 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.
@ -677,11 +666,10 @@ public class DefaultPluginVersionManager
boolean pluginValid = true; boolean pluginValid = true;
// if we don't have the required Maven version, then ignore an update // if we don't have the required Maven version, then ignore an update
if ( pluginProject.getPrerequisites() != null && if ( pluginProject.getPrerequisites() != null && pluginProject.getPrerequisites().getMaven() != null )
pluginProject.getPrerequisites().getMaven() != null )
{ {
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion( DefaultArtifactVersion requiredVersion =
pluginProject.getPrerequisites().getMaven() ); new DefaultArtifactVersion( pluginProject.getPrerequisites().getMaven() );
if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 ) if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 )
{ {