PR: MNG-297

Make sure that the base version is correctly set to -SNAPSHOT instead of a resolved timestamp when appropriate


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163916 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-12 23:51:21 +00:00
parent 4493e3cbeb
commit f86ee59771
3 changed files with 26 additions and 5 deletions

View File

@ -57,6 +57,7 @@ public class SnapshotTransformation
Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() ); Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() );
if ( m.matches() ) if ( m.matches() )
{ {
// This corrects the base version, but ensure it is not resolved again
artifact.setBaseVersion( m.group( 1 ) + "-SNAPSHOT" ); artifact.setBaseVersion( m.group( 1 ) + "-SNAPSHOT" );
} }
else if ( isSnapshot( artifact ) ) else if ( isSnapshot( artifact ) )
@ -205,6 +206,11 @@ public class SnapshotTransformation
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() );
if ( m.matches() )
{
artifact.setBaseVersion( m.group( 1 ) + "-SNAPSHOT" );
}
try try
{ {
SnapshotArtifactMetadata metadata = SnapshotArtifactMetadata.readFromLocalRepository( artifact, SnapshotArtifactMetadata metadata = SnapshotArtifactMetadata.readFromLocalRepository( artifact,
@ -228,7 +234,13 @@ public class SnapshotTransformation
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository ) public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException 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, SnapshotArtifactMetadata metadata = SnapshotArtifactMetadata.retrieveFromRemoteRepository( artifact,
remoteRepository, remoteRepository,

View File

@ -31,8 +31,6 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -60,7 +58,9 @@ public class DefaultModelInheritanceAssembler
// currentVersion // currentVersion
if ( child.getVersion() == null ) 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 // inceptionYear
@ -158,7 +158,7 @@ public class DefaultModelInheritanceAssembler
// Plugin Repositories :: aggregate // Plugin Repositories :: aggregate
List parentPluginRepositories = parent.getPluginRepositories(); List parentPluginRepositories = parent.getPluginRepositories();
List childPluginRepositories = child.getPluginRepositories(); List childPluginRepositories = child.getPluginRepositories();
for ( Iterator iterator = parentPluginRepositories.iterator(); iterator.hasNext(); ) for ( Iterator iterator = parentPluginRepositories.iterator(); iterator.hasNext(); )
{ {
Repository repository = (Repository) iterator.next(); Repository repository = (Repository) iterator.next();

View File

@ -19,6 +19,7 @@ package org.apache.maven.project.inheritance;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.maven.model.Build; import org.apache.maven.model.Build;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Resource; import org.apache.maven.model.Resource;
import org.apache.maven.model.Scm; import org.apache.maven.model.Scm;
@ -61,6 +62,12 @@ public class DefaultModelInheritanceAssemblerTest
Model child = new Model(); 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" ); child.setPackaging( "plugin" );
Build childBuild = new Build(); Build childBuild = new Build();
@ -257,6 +264,8 @@ public class DefaultModelInheritanceAssemblerTest
model.setArtifactId( artifactId ); model.setArtifactId( artifactId );
model.setVersion( "1.0" );
if ( connection != null || developerConnection != null || url != null ) if ( connection != null || developerConnection != null || url != null )
{ {
Scm scm = new Scm(); Scm scm = new Scm();