diff --git a/versions-maven-plugin/src/it-repo/it-resolve-ranges-issue-1121-parent.pom b/versions-maven-plugin/src/it-repo/it-resolve-ranges-issue-1121-parent.pom new file mode 100644 index 0000000000..da57e65cb0 --- /dev/null +++ b/versions-maven-plugin/src/it-repo/it-resolve-ranges-issue-1121-parent.pom @@ -0,0 +1,22 @@ + + 4.0.0 + + localhost + it-resolve-ranges-issue-1121-parent + 1.0 + pom + + + 1.1.1 + + + + + localhost + dummy-api + ${dummy.api.version} + + + + diff --git a/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/invoker.properties new file mode 100644 index 0000000000..bdb73fc388 --- /dev/null +++ b/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/invoker.properties @@ -0,0 +1 @@ +invoker.goals=-X ${project.groupId}:${project.artifactId}:${project.version}:resolve-ranges diff --git a/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/pom.xml new file mode 100644 index 0000000000..38e70793cb --- /dev/null +++ b/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/pom.xml @@ -0,0 +1,19 @@ + + 4.0.0 + + + localhost + it-resolve-ranges-issue-1121-parent + 1.0 + + it-resolve-ranges-issues-1121 + pom + resolve-ranges IT issue 1121 + + Test that resolve-ranges recognizes a property that overrides a property in its parent that is used as a version itself + + + [1,3.0) + + diff --git a/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/verify.bsh b/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/verify.bsh new file mode 100644 index 0000000000..82ecabcd30 --- /dev/null +++ b/versions-maven-plugin/src/it/it-resolve-ranges-issue-1121/verify.bsh @@ -0,0 +1,21 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + File file = new File( basedir, "pom.xml" ); + String buf = FileUtils.fileRead( file, "UTF-8" ); + + if ( buf.indexOf( "2.1" ) < 0 ) + { + System.err.println( "Version of dummy-api not resolved" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 8b12b5ca4f..4fba62e60e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -25,8 +25,10 @@ import java.util.Collection; import java.util.Map; import java.util.Optional; +import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; @@ -277,6 +279,11 @@ private void resolveRanges(ModifiedPomXMLEventReader pom, Collection private void resolvePropertyRanges(ModifiedPomXMLEventReader pom) throws XMLStreamException, MojoExecutionException { + if (includeProperties == null) { + Properties originalProperties = getProject().getOriginalModel().getProperties(); + includeProperties = + originalProperties.stringPropertyNames().stream().collect(Collectors.joining(",")); + } Map propertyVersions = this.getHelper() .getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest.builder() .withMavenProject(getProject())