mirror of https://github.com/apache/maven.git
use a regex to parse for more consistency
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163768 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d60fd2d736
commit
ba288cee61
|
@ -31,6 +31,8 @@ import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the information stored for a snapshot.
|
* Contains the information stored for a snapshot.
|
||||||
|
@ -54,6 +56,8 @@ public class SnapshotArtifactMetadata
|
||||||
|
|
||||||
private long lastModified = 0;
|
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 )
|
public SnapshotArtifactMetadata( Artifact artifact )
|
||||||
{
|
{
|
||||||
super( artifact, artifact.getArtifactId() + "-" + artifact.getBaseVersion() + "." + SNAPSHOT_VERSION_FILE );
|
super( artifact, artifact.getArtifactId() + "-" + artifact.getBaseVersion() + "." + SNAPSHOT_VERSION_FILE );
|
||||||
|
@ -169,28 +173,16 @@ public class SnapshotArtifactMetadata
|
||||||
String version = FileUtils.fileRead( file );
|
String version = FileUtils.fileRead( file );
|
||||||
lastModified = file.lastModified();
|
lastModified = file.lastModified();
|
||||||
|
|
||||||
/* TODO: try this
|
Matcher matcher = VERSION_FILE_PATTERN.matcher( version );
|
||||||
if( version.matches( "/^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$/" ))
|
if ( matcher.matches() )
|
||||||
{
|
{
|
||||||
|
timestamp = matcher.group( 2 );
|
||||||
|
buildNumber = Integer.valueOf( matcher.group( 3 ) ).intValue();
|
||||||
}
|
}
|
||||||
*/
|
else
|
||||||
|
|
||||||
int index = version.lastIndexOf( "-" );
|
|
||||||
if ( version.indexOf( "SNAPSHOT" ) >= 0 || index < 0 )
|
|
||||||
{
|
{
|
||||||
timestamp = null;
|
timestamp = null;
|
||||||
buildNumber = 0;
|
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 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue