ReleaseResult result )
throws ReleaseExecutionException
{
String nextVersion = null;
VersionInfo currentVersionInfo = null;
VersionInfo releaseVersionInfo = null;
boolean releaseVersionIsExplicit = false;
VersionInfo nextSnapshotVersionInfo = null;
boolean nextSnapshotVersionIsExplicit = false;
try
{
currentVersionInfo = new DefaultVersionInfo( project.getVersion() );
// The release/branch version defaults to currentVersionInfo (snapshot for branch, and release for tag)
releaseVersionInfo = currentVersionInfo;
// Check if the user specified a release version
if ( releaseDescriptor.getDefaultReleaseVersion() != null )
{
releaseVersionInfo = new DefaultVersionInfo( releaseDescriptor.getDefaultReleaseVersion() );
releaseVersionIsExplicit = true;
}
if ( releaseDescriptor.getReleaseVersions() != null )
{
String releaseVersion = ( String ) releaseDescriptor.getReleaseVersions().get( projectId );
if ( releaseVersion != null )
{
releaseVersionInfo = new DefaultVersionInfo( releaseVersion );
releaseVersionIsExplicit = true;
}
}
// The next snapshot version defaults to the next version after the release version
nextSnapshotVersionInfo = releaseVersionInfo.getNextVersion();
// Check if the user specified a new snapshot version
if ( releaseDescriptor.getDefaultDevelopmentVersion() != null )
{
nextSnapshotVersionInfo = new DefaultVersionInfo( releaseDescriptor.getDefaultDevelopmentVersion() );
nextSnapshotVersionIsExplicit = true;
}
if ( releaseDescriptor.getDevelopmentVersions() != null )
{
String nextDevVersion = ( String ) releaseDescriptor.getDevelopmentVersions().get( projectId );
if ( nextDevVersion != null )
{
nextSnapshotVersionInfo = new DefaultVersionInfo( nextDevVersion );
nextSnapshotVersionIsExplicit = true;
}
}
}
catch ( VersionParseException e )
{
String msg = "Error parsing version, cannot determine next version: " + e.getMessage();
if ( releaseDescriptor.isInteractive() )
{
logWarn( result, msg );
logDebug( result, e.getMessage(), e );
// set defaults for resume in interactive mode
if ( releaseVersionInfo == null )
{
try
{
releaseVersionInfo = new DefaultVersionInfo( "1.0" );
}
catch ( VersionParseException e1 )
{
// if that happens we are in serious trouble!
throw new ReleaseExecutionException( "Version 1.0 could not be parsed!", e1 );
}
}
if ( nextSnapshotVersionInfo == null )
{
nextSnapshotVersionInfo = releaseVersionInfo.getNextVersion();
}
}
else
{
// cannot proceed without a next value in batch mode
throw new ReleaseExecutionException( msg, e );
}
}
try
{
if ( convertToSnapshot )
{
if ( releaseDescriptor.isBranchCreation() )
{
if ( convertToBranch )
{
// branch modification
if ( releaseDescriptor.isUpdateBranchVersions()
&& ( ArtifactUtils.isSnapshot( project.getVersion() ) || releaseDescriptor.isUpdateVersionsToSnapshot() ) )
{
nextVersion = releaseVersionInfo.getSnapshotVersionString();
if ( !releaseVersionIsExplicit && releaseDescriptor.isInteractive() )
{
nextVersion = prompter.prompt(
"What is the branch version for \"" + project.getName() + "\"? (" + projectId + ")",
nextVersion );
}
}
else
{
nextVersion = project.getVersion();
}
}
else
{
// working copy modification
if ( ArtifactUtils.isSnapshot( project.getVersion() )
&& releaseDescriptor.isUpdateWorkingCopyVersions() )
{
nextVersion = nextSnapshotVersionInfo.getSnapshotVersionString();
if ( releaseDescriptor.isInteractive() && !nextSnapshotVersionIsExplicit )
{
nextVersion =
prompter.prompt( "What is the new working copy version for \"" + project.getName()
+ "\"? (" + projectId + ")", nextVersion );
}
}
else
{
nextVersion = project.getVersion();
}
}
}
else
{
if( releaseDescriptor.isUpdateWorkingCopyVersions() )
{
nextVersion = nextSnapshotVersionInfo.getSnapshotVersionString();
if ( releaseDescriptor.isInteractive() && !nextSnapshotVersionIsExplicit )
{
nextVersion =
prompter.prompt( "What is the new development version for \"" + project.getName() + "\"? ("
+ projectId + ")", nextVersion );