diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java index a78ea515b2..91ccab057d 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java @@ -57,6 +57,7 @@ public class SnapshotTransformation Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() ); if ( m.matches() ) { + // This corrects the base version, but ensure it is not resolved again artifact.setBaseVersion( m.group( 1 ) + "-SNAPSHOT" ); } else if ( isSnapshot( artifact ) ) @@ -205,6 +206,11 @@ public class SnapshotTransformation public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) throws ArtifactMetadataRetrievalException { + Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() ); + if ( m.matches() ) + { + artifact.setBaseVersion( m.group( 1 ) + "-SNAPSHOT" ); + } try { SnapshotArtifactMetadata metadata = SnapshotArtifactMetadata.readFromLocalRepository( artifact, @@ -228,7 +234,13 @@ public class SnapshotTransformation public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException { - if ( isSnapshot( artifact ) ) + Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() ); + if ( m.matches() ) + { + // This corrects the base version, but ensure it is not updated again + artifact.setBaseVersion( m.group( 1 ) + "-SNAPSHOT" ); + } + else if ( isSnapshot( artifact ) ) { SnapshotArtifactMetadata metadata = SnapshotArtifactMetadata.retrieveFromRemoteRepository( artifact, remoteRepository, diff --git a/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java b/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java index 38da7c1232..4512351052 100644 --- a/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java +++ b/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java @@ -31,8 +31,6 @@ import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; -import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -60,7 +58,9 @@ public class DefaultModelInheritanceAssembler // currentVersion if ( child.getVersion() == null ) { - child.setVersion( parent.getVersion() ); + // The parent version may have resolved to something different, so we take what we asked for... + // instead of - child.setVersion( parent.getVersion() ); + child.setVersion( child.getParent().getVersion() ); } // inceptionYear @@ -158,7 +158,7 @@ public class DefaultModelInheritanceAssembler // Plugin Repositories :: aggregate List parentPluginRepositories = parent.getPluginRepositories(); List childPluginRepositories = child.getPluginRepositories(); - + for ( Iterator iterator = parentPluginRepositories.iterator(); iterator.hasNext(); ) { Repository repository = (Repository) iterator.next(); diff --git a/maven-core/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java b/maven-core/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java index f30ee75cda..25bba04818 100644 --- a/maven-core/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java +++ b/maven-core/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java @@ -19,6 +19,7 @@ package org.apache.maven.project.inheritance; import junit.framework.TestCase; import org.apache.maven.model.Build; import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; @@ -61,6 +62,12 @@ public class DefaultModelInheritanceAssemblerTest Model child = new Model(); + Parent parentElement = new Parent(); + parentElement.setArtifactId( parent.getArtifactId() ); + parentElement.setGroupId( parent.getGroupId() ); + parentElement.setVersion( parent.getVersion() ); + child.setParent( parentElement ); + child.setPackaging( "plugin" ); Build childBuild = new Build(); @@ -257,6 +264,8 @@ public class DefaultModelInheritanceAssemblerTest model.setArtifactId( artifactId ); + model.setVersion( "1.0" ); + if ( connection != null || developerConnection != null || url != null ) { Scm scm = new Scm();