maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform SnapshotTransformation.java
Date Tue, 12 Apr 2005 23:51:21 GMT
brett       2005/04/12 16:51:21

  Modified:    maven-core/src/main/java/org/apache/maven/project/inheritance
                        DefaultModelInheritanceAssembler.java
               maven-core/src/test/java/org/apache/maven/project/inheritance
                        DefaultModelInheritanceAssemblerTest.java
               maven-artifact/src/main/java/org/apache/maven/artifact/transform
                        SnapshotTransformation.java
  Log:
  PR: MNG-297
  Make sure that the base version is correctly set to -SNAPSHOT instead of a resolved timestamp
when appropriate
  
  Revision  Changes    Path
  1.28      +4 -4      maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
  
  Index: DefaultModelInheritanceAssembler.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- DefaultModelInheritanceAssembler.java	6 Apr 2005 01:28:29 -0000	1.27
  +++ DefaultModelInheritanceAssembler.java	12 Apr 2005 23:51:21 -0000	1.28
  @@ -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 @@
           // 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 @@
           // Plugin Repositories :: aggregate
           List parentPluginRepositories = parent.getPluginRepositories();
           List childPluginRepositories = child.getPluginRepositories();
  -        
  +
           for ( Iterator iterator = parentPluginRepositories.iterator(); iterator.hasNext();
)
           {
               Repository repository = (Repository) iterator.next();
  
  
  
  1.12      +9 -0      maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java
  
  Index: DefaultModelInheritanceAssemblerTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultModelInheritanceAssemblerTest.java	10 Mar 2005 01:35:14 -0000	1.11
  +++ DefaultModelInheritanceAssemblerTest.java	12 Apr 2005 23:51:21 -0000	1.12
  @@ -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 @@
   
           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 @@
   
           model.setArtifactId( artifactId );
   
  +        model.setVersion( "1.0" );
  +
           if ( connection != null || developerConnection != null || url != null )
           {
               Scm scm = new Scm();
  
  
  
  1.20      +13 -1     maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java
  
  Index: SnapshotTransformation.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- SnapshotTransformation.java	7 Apr 2005 02:28:25 -0000	1.19
  +++ SnapshotTransformation.java	12 Apr 2005 23:51:21 -0000	1.20
  @@ -57,6 +57,7 @@
           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 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 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,
  
  
  

Mime
View raw message