Resolving: MNG-876. Versions are incremented correctly again.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@289348 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-09-15 23:36:29 +00:00
parent 8efd4bce77
commit 5038a4d249
3 changed files with 18 additions and 10 deletions

View File

@ -30,7 +30,9 @@ public final class ArtifactUtils
public static boolean isSnapshot( String version ) public static boolean isSnapshot( String version )
{ {
return version != null && ( version.toUpperCase().endsWith( "SNAPSHOT" ) || Artifact.VERSION_FILE_PATTERN.matcher( version ).matches() ); return version != null
&& ( version.toUpperCase().endsWith( "SNAPSHOT" ) || Artifact.VERSION_FILE_PATTERN.matcher( version )
.matches() );
} }
public static String versionlessKey( Artifact artifact ) public static String versionlessKey( Artifact artifact )

View File

@ -239,8 +239,7 @@ public class PrepareReleaseMojo
} }
} }
//TODO reinstate. removeReleasePoms();
// removeReleasePoms();
checkInNextSnapshot(); checkInNextSnapshot();

View File

@ -86,7 +86,7 @@ public class ProjectVersionResolver
{ {
String projectVersion = project.getOriginalModel().getVersion(); String projectVersion = project.getOriginalModel().getVersion();
if ( projectVersion.endsWith( "SNAPSHOT" ) ) if ( ArtifactUtils.isSnapshot( projectVersion ) )
{ {
String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
throw new MojoExecutionException( "The project " + projectId + " is a snapshot (" + projectVersion + throw new MojoExecutionException( "The project " + projectId + " is a snapshot (" + projectVersion +
@ -103,17 +103,25 @@ public class ProjectVersionResolver
// releaseVersion = 1.0.4 // releaseVersion = 1.0.4
// snapshotVersion = 1.0.5-SNAPSHOT // snapshotVersion = 1.0.5-SNAPSHOT
String staticVersionPart = null;
String nextVersionString = null; String nextVersionString = null;
if ( projectVersion.indexOf( "-" ) > 0 )
int dashIdx = projectVersion.lastIndexOf( "-" );
int dotIdx = projectVersion.lastIndexOf( "." );
if ( dashIdx > 0 )
{ {
nextVersionString = projectVersion.substring( projectVersion.lastIndexOf( "-" ) + 1 ); staticVersionPart = projectVersion.substring( 0, dashIdx + 1 );
nextVersionString = projectVersion.substring( dashIdx + 1 );
} }
else if ( projectVersion.indexOf( "." ) > 0 ) else if ( dotIdx > 0 )
{ {
nextVersionString = projectVersion.substring( projectVersion.lastIndexOf( "." ) + 1 ); staticVersionPart = projectVersion.substring( 0, dotIdx + 1 );
nextVersionString = projectVersion.substring( dotIdx + 1 );
} }
else else
{ {
staticVersionPart = "";
nextVersionString = projectVersion; nextVersionString = projectVersion;
} }
@ -121,8 +129,7 @@ public class ProjectVersionResolver
{ {
nextVersionString = Integer.toString( Integer.parseInt( nextVersionString ) + 1 ); nextVersionString = Integer.toString( Integer.parseInt( nextVersionString ) + 1 );
projectVersion = projectVersion.substring( 0, projectVersion.lastIndexOf( "-" ) + 1 ) + nextVersionString + projectVersion = staticVersionPart + nextVersionString + SNAPSHOT_CLASSIFIER;
SNAPSHOT_CLASSIFIER;
} }
catch ( NumberFormatException e ) catch ( NumberFormatException e )
{ {