diff --git a/src/it/released-version-version-prefix/invoker.properties b/src/it/released-version-version-prefix/invoker.properties new file mode 100644 index 00000000..a48f6073 --- /dev/null +++ b/src/it/released-version-version-prefix/invoker.properties @@ -0,0 +1,3 @@ +invoker.goals = test +invoker.buildResult = success +invoker.settingsFile = src/it/released-version-existing-asset/settings-maven-central.xml diff --git a/src/it/released-version-version-prefix/pom.xml b/src/it/released-version-version-prefix/pom.xml new file mode 100644 index 00000000..2f26102a --- /dev/null +++ b/src/it/released-version-version-prefix/pom.xml @@ -0,0 +1,68 @@ + + 4.0.0 + + + org.apache.continuum + continuum + 1.0-SNAPSHOT + build-helper-maven-plugin-released-version-it-mojo-parent + + + package + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + released-version + + released-version + + + 1.3 + myReleasedVersion + + + + + + maven-antrun-plugin + + + mk-target-dir + compile + + run + + + + + + + + + + echo-released-version + test + + run + + + + myReleasedVersion.version=${myReleasedVersion.version} + myReleasedVersion.majorVersion=${myReleasedVersion.majorVersion} + myReleasedVersion.minorVersion=${myReleasedVersion.minorVersion} + myReleasedVersion.incrementalVersion=${myReleasedVersion.incrementalVersion} + + + + + + + + + diff --git a/src/it/released-version-version-prefix/settings-maven-central.xml b/src/it/released-version-version-prefix/settings-maven-central.xml new file mode 100644 index 00000000..e112181a --- /dev/null +++ b/src/it/released-version-version-prefix/settings-maven-central.xml @@ -0,0 +1,27 @@ + + + + + default + + + central + https://repo1.maven.org/maven2/ + default + + + + + central + https://repo1.maven.org/maven2/ + default + + + + + + default + + diff --git a/src/it/released-version-version-prefix/verify.groovy b/src/it/released-version-version-prefix/verify.groovy new file mode 100644 index 00000000..e6c9d235 --- /dev/null +++ b/src/it/released-version-version-prefix/verify.groovy @@ -0,0 +1,12 @@ +File file = new File( basedir, "build.log" ); +assert file.exists(); + +String text = file.getText("utf-8"); + +// assert latest release of org.apache.continuum:continuum - it's in apache attic, there will be no new releases any more +assert text.contains("myReleasedVersion.version=1.3.8") +assert text.contains("myReleasedVersion.majorVersion=1") +assert text.contains("myReleasedVersion.minorVersion=3") +assert text.contains("myReleasedVersion.incrementalVersion=8") + +return true; diff --git a/src/main/java/org/codehaus/mojo/buildhelper/ReleasedVersionMojo.java b/src/main/java/org/codehaus/mojo/buildhelper/ReleasedVersionMojo.java index 77d3c7fa..ca6cf53e 100644 --- a/src/main/java/org/codehaus/mojo/buildhelper/ReleasedVersionMojo.java +++ b/src/main/java/org/codehaus/mojo/buildhelper/ReleasedVersionMojo.java @@ -73,6 +73,13 @@ public class ReleasedVersionMojo @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true ) private List remoteArtifactRepositories; + /** + * Returned version must before with the version prefix. Allows searching for maximum minor version given a major + * version, or maximum increment version given a minor version. + */ + @Parameter( property = "releasedVersion.versionPrefix" ) + private String versionPrefix = ""; + /** * Prefix string to use for the set of version properties. */ @@ -111,7 +118,8 @@ public void execute() remoteArtifactRepositories ); for ( ArtifactVersion version : versions ) { - if ( !ArtifactUtils.isSnapshot( version.toString() ) + if ( version.toString().startsWith(versionPrefix) + && !ArtifactUtils.isSnapshot( version.toString() ) && ( releasedVersion == null || version.compareTo( releasedVersion ) > 0 ) ) { releasedVersion = version;