o Fix prepare release for poms with non snapshot parent

o Fix version resolver for version without "-" like -alpha-2 but 1.0.2

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@279767 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-09-09 13:26:54 +00:00
parent 9c060b192a
commit cbf7453e2d
2 changed files with 33 additions and 7 deletions

View File

@ -540,12 +540,23 @@ public class PrepareReleaseMojo
{
MavenProject parentProject = currentProject.getParent();
String parentVersion = getVersionResolver().getResolvedVersion( parentProject.getGroupId(),
parentProject.getArtifactId() );
String parentVersion = null;
if ( isSnapshot( parentVersion ) )
if ( isSnapshot( parentProject.getVersion() ) )
{
throw new MojoExecutionException( "Can't release project due to non released parent." );
parentVersion = getVersionResolver().getResolvedVersion( parentProject.getGroupId(),
parentProject.getArtifactId() );
if ( parentVersion == null )
{
parentVersion = parentProject.getVersion();
}
if ( isSnapshot( parentVersion ) )
{
throw new MojoExecutionException( "Can't release project due to non released parent (" +
parentProject.getGroupId() + ":" + parentProject.getArtifactId() + parentVersion + "." );
}
}
currentProject = parentProject;

View File

@ -86,10 +86,10 @@ public class ProjectVersionResolver
{
String projectVersion = project.getOriginalModel().getVersion();
if ( project.getVersion().endsWith( "SNAPSHOT" ) )
if ( projectVersion.endsWith( "SNAPSHOT" ) )
{
String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
throw new MojoExecutionException( "The project " + projectId + " is a snapshot (" + project.getVersion() +
throw new MojoExecutionException( "The project " + projectId + " is a snapshot (" + projectVersion +
"). It appears that the release version has not been committed." );
}
@ -99,8 +99,23 @@ public class ProjectVersionResolver
// releaseVersion = 1.0-beta-4
// snapshotVersion = 1.0-beta-5-SNAPSHOT
// or
// releaseVersion = 1.0.4
// snapshotVersion = 1.0.5-SNAPSHOT
String nextVersionString = projectVersion.substring( projectVersion.lastIndexOf( "-" ) + 1 );
String nextVersionString = null;
if ( projectVersion.indexOf( "-" ) > 0 )
{
nextVersionString = projectVersion.substring( projectVersion.lastIndexOf( "-" ) + 1 );
}
else if ( projectVersion.indexOf( "." ) > 0 )
{
nextVersionString = projectVersion.substring( projectVersion.lastIndexOf( "." ) + 1 );
}
else
{
nextVersionString = projectVersion;
}
try
{