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/metadata SnapshotArtifactMetadata.java
Date Mon, 04 Apr 2005 16:02:48 GMT
brett       2005/04/04 09:02:48

  Modified:    maven-artifact/src/main/java/org/apache/maven/artifact/metadata
                        SnapshotArtifactMetadata.java
  Log:
  use a regex to parse for more consistency
  
  Revision  Changes    Path
  1.13      +10 -18    maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java
  
  Index: SnapshotArtifactMetadata.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SnapshotArtifactMetadata.java	4 Apr 2005 14:35:06 -0000	1.12
  +++ SnapshotArtifactMetadata.java	4 Apr 2005 16:02:48 -0000	1.13
  @@ -31,6 +31,8 @@
   import java.text.SimpleDateFormat;
   import java.util.Date;
   import java.util.TimeZone;
  +import java.util.regex.Matcher;
  +import java.util.regex.Pattern;
   
   /**
    * Contains the information stored for a snapshot.
  @@ -54,6 +56,8 @@
   
       private long lastModified = 0;
   
  +    private static final Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$"
);
  +
       public SnapshotArtifactMetadata( Artifact artifact )
       {
           super( artifact, artifact.getArtifactId() + "-" + artifact.getBaseVersion() + "."
+ SNAPSHOT_VERSION_FILE );
  @@ -169,28 +173,16 @@
           String version = FileUtils.fileRead( file );
           lastModified = file.lastModified();
   
  -/* TODO: try this
  -        if( version.matches( "/^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$/" ))
  +        Matcher matcher = VERSION_FILE_PATTERN.matcher( version );
  +        if ( matcher.matches() )
           {
  -
  +            timestamp = matcher.group( 2 );
  +            buildNumber = Integer.valueOf( matcher.group( 3 ) ).intValue();
           }
  -*/
  -
  -        int index = version.lastIndexOf( "-" );
  -        if ( version.indexOf( "SNAPSHOT" ) >= 0 || index < 0 )
  +        else
           {
               timestamp = null;
               buildNumber = 0;
  -            return;
  -        }
  -
  -        timestamp = version.substring( 0, index );
  -        buildNumber = Integer.valueOf( version.substring( index + 1 ) ).intValue();
  -        index = timestamp.lastIndexOf( "-" );
  -        if ( index >= 0 )
  -        {
  -            // ignore starting version part, will be prepended later
  -            timestamp = timestamp.substring( index + 1 );
           }
       }
   
  
  
  

Mime
View raw message