Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

363:Force update parent version with real version #364

Merged
merged 8 commits into from Jul 8, 2021
Expand Up @@ -417,10 +417,16 @@ protected abstract void update( ModifiedPomXMLEventReader pom )
* @return <code>true</code> if the update should be applied.
* @since 1.0-alpha-1
*/
protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion )
protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, Boolean forceUpdate )
akilantech marked this conversation as resolved.
Show resolved Hide resolved
{
getLog().debug( "Proposal is to update from " + currentVersion + " to " + updateVersion );

if ( forceUpdate == Boolean.TRUE )
akilantech marked this conversation as resolved.
Show resolved Hide resolved
{
getLog().info( "Force update enabled. LATEST or RELEASE versions will be overwritten with real version" );
return true;
}

if ( updateVersion == null )
{
getLog().warn( "Not updating version: could not resolve any versions" );
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java
Expand Up @@ -54,6 +54,14 @@ public class UpdateParentMojo
@Parameter( property = "parentVersion", defaultValue = "null" )
protected String parentVersion = null;

/**
* to update parent version by force when it is RELEASE or LATEST
*
* @since 2.8
*/
@Parameter( property = "forceUpdate", defaultValue = "False" )
akilantech marked this conversation as resolved.
Show resolved Hide resolved
protected boolean forceUpdate = false;

// -------------------------- OTHER METHODS --------------------------

/**
Expand Down Expand Up @@ -111,7 +119,7 @@ protected void update( ModifiedPomXMLEventReader pom )
throw new MojoExecutionException( e.getMessage(), e );
}

if ( !shouldApplyUpdate( artifact, currentVersion, artifactVersion ) )
if ( !shouldApplyUpdate( artifact, currentVersion, artifactVersion, forceUpdate ) )
{
return;
}
Expand Down