diff --git a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/MavenLocationUpdater.java b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/MavenLocationUpdater.java index 52e840f7c7..3fd175237f 100644 --- a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/MavenLocationUpdater.java +++ b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/MavenLocationUpdater.java @@ -13,6 +13,8 @@ package org.eclipse.tycho.versionbump; import java.util.Map; +import java.util.Objects; +import java.util.Optional; import javax.inject.Inject; import javax.inject.Named; @@ -58,7 +60,9 @@ boolean update(Element mavenLocation, UpdateTargetMojo context) throws VersionRa Dependency mavenDependency = getDependency(dependency); Artifact dependencyArtifact = helper.createDependencyArtifact(mavenDependency); ArtifactVersions versions = helper.lookupArtifactVersions(dependencyArtifact, false); - ArtifactVersion updateVersion = versions.getNewestUpdateWithinSegment(context.getSegment(), false); + ArtifactVersion updateVersion = context.getSegments() + .map(seg -> versions.getNewestUpdateWithinSegment(Optional.of(seg), false)) + .filter(Objects::nonNull).findFirst().orElse(null); if (updateVersion != null) { String oldVersion = mavenDependency.getVersion(); String newVersion = updateVersion.toString(); diff --git a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateTargetMojo.java b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateTargetMojo.java index 1536b591e8..c296b2a938 100644 --- a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateTargetMojo.java +++ b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateTargetMojo.java @@ -21,8 +21,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.List; -import java.util.Optional; import java.util.Set; +import java.util.stream.Stream; +import java.util.stream.Stream.Builder; import javax.inject.Inject; @@ -90,6 +91,13 @@ public class UpdateTargetMojo extends AbstractUpdateMojo { @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") private boolean allowIncrementalUpdates; + /** + * Whether to allow the subIncremental version number to be changed. + * + */ + @Parameter(property = "allowSubIncrementalUpdates", defaultValue = "true") + private boolean allowSubIncrementalUpdates; + /** * A comma separated list of update site discovery strategies, the following is currently * supported: @@ -205,18 +213,22 @@ protected File getFileToBeUpdated() throws MojoFailureException { } } - boolean isAllowIncrementalUpdates() { - return allowIncrementalUpdates; + boolean isAllowSubIncrementalUpdates() { + return allowSubIncrementalUpdates; } - boolean isAllowMajorUpdates() { - return allowMajorUpdates; + boolean isAllowIncrementalUpdates() { + return allowIncrementalUpdates; } boolean isAllowMinorUpdates() { return allowMinorUpdates; } + boolean isAllowMajorUpdates() { + return allowMajorUpdates; + } + MavenSession getMavenSession() { return mavenSession; } @@ -259,14 +271,21 @@ String getMavenRulesUri() { return mavenRulesUri; } - Optional getSegment() { - if (isAllowMajorUpdates() && isAllowMinorUpdates() && isAllowIncrementalUpdates()) { - return Optional.empty(); + Stream getSegments() { + Builder builder = Stream.builder(); + if (isAllowMajorUpdates()) { + builder.accept(Segment.MAJOR); + } + if (isAllowMinorUpdates()) { + builder.accept(Segment.MINOR); + } + if (isAllowIncrementalUpdates()) { + builder.accept(Segment.INCREMENTAL); } - if (isAllowMinorUpdates() && isAllowIncrementalUpdates()) { - return Optional.of(Segment.MINOR); + if (isAllowSubIncrementalUpdates()) { + builder.accept(Segment.SUBINCREMENTAL); } - return Optional.of(Segment.INCREMENTAL); + return builder.build(); } }