diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 62e2cc68f5..0e0aeca7b7 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -87,6 +87,30 @@ public class DisplayPropertyUpdatesMojo @Parameter( property = "autoLinkItems", defaultValue = "true" ) private boolean autoLinkItems; + /** + * Whether to allow the major version number to be changed. + * + * @since 2.5 + */ + @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + private boolean allowMajorUpdates; + + /** + * Whether to allow the minor version number to be changed. + * + * @since 2.5 + */ + @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + private boolean allowMinorUpdates; + + /** + * Whether to allow the incremental version number to be changed. + * + * @since 2.5 + */ + @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + private boolean allowIncrementalUpdates; + // -------------------------- STATIC METHODS -------------------------- // -------------------------- OTHER METHODS -------------------------- @@ -112,9 +136,9 @@ public void execute() continue; } - // FIXME: Check the parameters -1 ? correct? + int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, - this.reactorProjects, this.getHelper(), false, -1 ); + this.reactorProjects, this.getHelper(), false, segment ); if ( winner != null && !currentVersion.equals( winner.toString() ) ) { diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 6f749305e1..151978b732 100644 --- a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -74,6 +74,30 @@ public class ResolveRangesMojo @Parameter( property = "excludeProperties" ) private String excludeProperties = null; + /** + * Whether to allow the major version number to be changed. + * + * @since 2.5 + */ + @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + private boolean allowMajorUpdates; + + /** + * Whether to allow the minor version number to be changed. + * + * @since 2.5 + */ + @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + private boolean allowMinorUpdates; + + /** + * Whether to allow the incremental version number to be changed. + * + * @since 2.5 + */ + @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + private boolean allowIncrementalUpdates; + // ------------------------------ FIELDS ------------------------------ /** @@ -253,7 +277,10 @@ private void resolvePropertyRanges( ModifiedPomXMLEventReader pom ) } property.setVersion( currentVersion ); - updatePropertyToNewestVersion( pom, property, version, currentVersion ); + + int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + // TODO: Check if we could add allowDowngrade ? + updatePropertyToNewestVersion( pom, property, version, currentVersion, false, segment ); } }