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 void transformForResolve( Artifact artifact, List remoteRepositories, Art
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 @@ private static String getCacheKey( Artifact artifact )
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 void transformForInstall( Artifact artifact, ArtifactRepository localRepo
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,

View File

@ -31,8 +31,6 @@
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 void assembleModelInheritance( Model child, Model parent )
// 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 void assembleModelInheritance( Model child, Model parent )
// Plugin Repositories :: aggregate
List parentPluginRepositories = parent.getPluginRepositories();
List childPluginRepositories = child.getPluginRepositories();
for ( Iterator iterator = parentPluginRepositories.iterator(); iterator.hasNext(); )
{
Repository repository = (Repository) iterator.next();

View File

@ -19,6 +19,7 @@
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 void testShouldOverrideUnitTestExcludesOnly()
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 @@ private Model makeScmModel( String artifactId, String connection, String develop
model.setArtifactId( artifactId );
model.setVersion( "1.0" );
if ( connection != null || developerConnection != null || url != null )
{
Scm scm = new Scm();