You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2005/10/11 16:18:11 UTC
svn commit: r312889 -
/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
Author: brett
Date: Tue Oct 11 07:18:06 2005
New Revision: 312889
URL: http://svn.apache.org/viewcvs?rev=312889&view=rev
Log:
look in the reactor and the current project for the appropriate version to use
(before the registry and repository, but after the build section)
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java?rev=312889&r1=312888&r2=312889&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java Tue Oct 11 07:18:06 2005
@@ -17,6 +17,7 @@
*/
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 @@
// 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 @@
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 @@
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 @@
}
}
- // 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 <useVersion/>
// 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 @@
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
project.replaceWithActiveArtifact( artifact );
-
+
String version = null;
if ( artifact.isResolved() )
@@ -651,7 +668,8 @@
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() );