more fixes to the release plugin

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@279328 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-07 14:27:51 +00:00
parent 7d198eb4ad
commit 7b6f292c73
2 changed files with 16 additions and 10 deletions

View File

@ -74,6 +74,8 @@ public class PrepareReleaseMojo
private static final String RELEASE_POM = "release-pom.xml";
private static final String POM = "pom.xml";
/**
* @parameter expression="${basedir}"
* @required
@ -255,12 +257,6 @@ public class PrepareReleaseMojo
private void transformPomToSnapshotVersionPom( MavenProject project )
throws MojoExecutionException
{
if ( isSnapshot( project.getVersion() ) )
{
throw new MojoExecutionException( "This project is a snapshot (" + project.getVersion() +
"). It appears that the release version has not been committed." );
}
Model model = project.getOriginalModel();
ProjectVersionResolver versionResolver = getVersionResolver();
@ -361,15 +357,17 @@ public class PrepareReleaseMojo
}
Writer writer = null;
File file = new File( project.getFile().getParentFile(), POM );
try
{
writer = new FileWriter( project.getFile() );
writer = new FileWriter( file );
project.writeOriginalModel( writer );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Cannot write development version of pom to: " + project.getFile(), e );
throw new MojoExecutionException( "Cannot write development version of pom to: " + file, e );
}
finally
{
@ -777,15 +775,16 @@ public class PrepareReleaseMojo
Writer writer = null;
File file = new File( project.getFile().getParentFile(), POM );
try
{
writer = new FileWriter( project.getFile() );
writer = new FileWriter( file );
project.writeOriginalModel( writer );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Cannot write released version of pom to: " + project.getFile(), e );
throw new MojoExecutionException( "Cannot write released version of pom to: " + file, e );
}
finally
{

View File

@ -86,6 +86,13 @@ public class ProjectVersionResolver
{
String projectVersion = project.getOriginalModel().getVersion();
if ( project.getVersion().endsWith( "SNAPSHOT" ) )
{
String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
throw new MojoExecutionException( "The project " + projectId + " is a snapshot (" + project.getVersion() +
"). It appears that the release version has not been committed." );
}
// TODO: we will need to incorporate versioning strategies here because it is unlikely
// that everyone will be able to agree on a standard. This is extremely limited right
// now and really only works for the way maven is versioned.