diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 8babe9d49a..234cf25b9a 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -409,6 +409,10 @@ protected abstract void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException; /** + * @deprecated + * This method no longer supported. + * use shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, Boolean forceUpdate ) + * * Returns true if the update should be applied. * * @param artifact The artifact. @@ -417,10 +421,31 @@ protected abstract void update( ModifiedPomXMLEventReader pom ) * @return true if the update should be applied. * @since 1.0-alpha-1 */ + @Deprecated protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion ) + { + return shouldApplyUpdate(artifact,currentVersion,updateVersion,false); + } + + /** + * Returns true if the update should be applied. + * + * @param artifact The artifact. + * @param currentVersion The current version of the artifact. + * @param updateVersion The proposed new version of the artifact. + * @return true if the update should be applied to the pom. + * @since 2.9 + */ + protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, boolean forceUpdate ) { getLog().debug( "Proposal is to update from " + currentVersion + " to " + updateVersion ); + if ( forceUpdate ) + { + 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" ); diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 840c6a0340..57335e6b95 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -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.9 + */ + @Parameter( property = "forceUpdate", defaultValue = "false" ) + protected boolean forceUpdate = false; + // -------------------------- OTHER METHODS -------------------------- /** @@ -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; } @@ -124,4 +132,4 @@ protected void update( ModifiedPomXMLEventReader pom ) } } -} \ No newline at end of file +}