From 3968063fb21ce0fbb83d1bd23812416e33ce986d Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Tue, 11 Oct 2005 14:18:06 +0000 Subject: [PATCH] look in the reactor and the current project for the appropriate version to use (before the registry and repository, but after the build section) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@312889 13f79535-47bb-0310-9956-ffa450edef68 --- .../version/DefaultPluginVersionManager.java | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java index d2d758eec7..63f9081da0 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java @@ -17,6 +17,7 @@ package org.apache.maven.plugin.version; */ import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -92,6 +93,25 @@ public class DefaultPluginVersionManager // first pass...if the plugin is specified in the pom, try to retrieve the version from there. String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin ); + // if there was no explicit version, try for one in the reactor + if ( version == null ) + { + // check self + if ( project.getGroupId().equals( groupId ) && project.getArtifactId().equals( artifactId ) ) + { + version = project.getVersion(); + } + else if ( project.getProjectReferences() != null ) + { + String refId = ArtifactUtils.versionlessKey( groupId, artifactId ); + MavenProject ref = (MavenProject) project.getProjectReferences().get( refId ); + if ( ref != null ) + { + version = ref.getVersion(); + } + } + } + // we're NEVER going to persist POM-derived plugin versions. String updatedVersion = null; @@ -121,8 +141,8 @@ public class DefaultPluginVersionManager if ( Boolean.TRUE.equals( pluginUpdateOverride ) || ( !Boolean.FALSE.equals( pluginUpdateOverride ) && shouldCheckForUpdates( groupId, artifactId ) ) ) { - updatedVersion = resolveMetaVersion( groupId, artifactId, project, - localRepository, Artifact.LATEST_VERSION ); + updatedVersion = resolveMetaVersion( groupId, artifactId, project, localRepository, + Artifact.LATEST_VERSION ); if ( StringUtils.isNotEmpty( updatedVersion ) && !updatedVersion.equals( version ) ) { @@ -154,8 +174,7 @@ public class DefaultPluginVersionManager if ( StringUtils.isEmpty( version ) ) { // 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 ); if ( version != null ) { @@ -168,14 +187,12 @@ public class DefaultPluginVersionManager } } - // TODO: Remove this...it shouldn't be needed anymore. Leaving it in for backward compat. // final pass...retrieve the version for RELEASE and also set that resolved version as the // in settings.xml. if ( StringUtils.isEmpty( version ) ) { // 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 ); if ( version != null ) { @@ -624,7 +641,7 @@ public class DefaultPluginVersionManager Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId ); project.replaceWithActiveArtifact( artifact ); - + String version = null; if ( artifact.isResolved() ) @@ -651,7 +668,8 @@ public class DefaultPluginVersionManager boolean pluginValid = true; // if we don't have the required Maven version, then ignore an update - if ( pluginProject.getPrerequisites() != null && pluginProject.getPrerequisites().getMaven() != null ) + if ( pluginProject.getPrerequisites() != null && + pluginProject.getPrerequisites().getMaven() != null ) { DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion( pluginProject.getPrerequisites().getMaven() );