diff --git a/echo/pom.xml b/echo/pom.xml
index da2a05e1..764b8160 100644
--- a/echo/pom.xml
+++ b/echo/pom.xml
@@ -4,7 +4,7 @@
org.sonarsource.orchestrator
orchestrator-parent
- 4.8-SNAPSHOT
+ 4.7.1-SNAPSHOT
echo
Echo Program
diff --git a/pom.xml b/pom.xml
index 80ba34ed..a7bc26ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
org.sonarsource.orchestrator
orchestrator-parent
- 4.8-SNAPSHOT
+ 4.7.1-SNAPSHOT
pom
Orchestrator :: Parent
2011
diff --git a/sonar-orchestrator-junit4/pom.xml b/sonar-orchestrator-junit4/pom.xml
index 860baa19..ddc801e4 100644
--- a/sonar-orchestrator-junit4/pom.xml
+++ b/sonar-orchestrator-junit4/pom.xml
@@ -5,7 +5,7 @@
org.sonarsource.orchestrator
orchestrator-parent
- 4.8-SNAPSHOT
+ 4.7.1-SNAPSHOT
sonar-orchestrator-junit4
Orchestrator - JUnit 4
diff --git a/sonar-orchestrator-junit5/pom.xml b/sonar-orchestrator-junit5/pom.xml
index 6347b60e..954415ae 100644
--- a/sonar-orchestrator-junit5/pom.xml
+++ b/sonar-orchestrator-junit5/pom.xml
@@ -5,7 +5,7 @@
org.sonarsource.orchestrator
orchestrator-parent
- 4.8-SNAPSHOT
+ 4.7.1-SNAPSHOT
sonar-orchestrator-junit5
Orchestrator - JUnit 5
diff --git a/sonar-orchestrator/pom.xml b/sonar-orchestrator/pom.xml
index 81e6cb1d..29f6697f 100644
--- a/sonar-orchestrator/pom.xml
+++ b/sonar-orchestrator/pom.xml
@@ -4,7 +4,7 @@
org.sonarsource.orchestrator
orchestrator-parent
- 4.8-SNAPSHOT
+ 4.7.1-SNAPSHOT
sonar-orchestrator
Orchestrator
diff --git a/sonar-orchestrator/src/main/java/com/sonar/orchestrator/util/MavenVersionResolver.java b/sonar-orchestrator/src/main/java/com/sonar/orchestrator/util/MavenVersionResolver.java
index 58351668..d7b8dcab 100644
--- a/sonar-orchestrator/src/main/java/com/sonar/orchestrator/util/MavenVersionResolver.java
+++ b/sonar-orchestrator/src/main/java/com/sonar/orchestrator/util/MavenVersionResolver.java
@@ -42,7 +42,7 @@ public class MavenVersionResolver {
private final String baseUrl;
private final String groupId;
private final String artifactId;
- private List versions;
+ private List versions;
public MavenVersionResolver(String baseUrl, String groupId, String artifactId) {
this.baseUrl = baseUrl;
@@ -53,7 +53,10 @@ public MavenVersionResolver(String baseUrl, String groupId, String artifactId) {
public void loadVersions() {
try {
MavenRepositoryVersion mavenMetadata = downloadVersions();
- this.versions = mavenMetadata.getVersioning().getVersions();
+ this.versions = mavenMetadata.getVersioning().getVersions()
+ .stream()
+ .map(Version::create)
+ .collect(Collectors.toList());
this.versions.sort(Comparator.naturalOrder());
} catch (IOException e) {
throw new IllegalStateException("Fail to load versions of " + groupId + ":" + artifactId, e);
@@ -62,16 +65,16 @@ public void loadVersions() {
public Optional getLatestVersion(@Nullable String majorMinorVersion) {
if (isEmpty(majorMinorVersion)) {
- return Optional.of(this.versions.get(versions.size() - 1));
+ Version version = this.versions.get(versions.size() - 1);
+ return Optional.of(version.toString());
}
- List filteredVersions = versions.stream()
- .filter(version -> version.startsWith(majorMinorVersion))
+ List filteredVersions = versions.stream()
+ .filter(version -> version.toString().startsWith(majorMinorVersion))
.collect(Collectors.toList());
if (!filteredVersions.isEmpty()) {
return filteredVersions.stream()
- .map(Version::create)
.max(Comparator.naturalOrder())
.map(Version::toString);
} else {
@@ -79,7 +82,7 @@ public Optional getLatestVersion(@Nullable String majorMinorVersion) {
}
}
- public MavenRepositoryVersion downloadVersions() throws IOException {
+ protected MavenRepositoryVersion downloadVersions() throws IOException {
URL url = getUrl();
return new XmlMapper().readValue(url, MavenRepositoryVersion.class);
}
diff --git a/sonar-orchestrator/src/test/java/com/sonar/orchestrator/util/MavenVersionResolverTest.java b/sonar-orchestrator/src/test/java/com/sonar/orchestrator/util/MavenVersionResolverTest.java
index 79f6e463..00077f93 100644
--- a/sonar-orchestrator/src/test/java/com/sonar/orchestrator/util/MavenVersionResolverTest.java
+++ b/sonar-orchestrator/src/test/java/com/sonar/orchestrator/util/MavenVersionResolverTest.java
@@ -39,7 +39,7 @@ class MavenVersionResolverTest {
@ParameterizedTest
@MethodSource("params")
- void loadVersions_whenProvidedEmptyString_shouldReturnLatest(String input, String output) throws IOException {
+ void loadVersions(String input, String output) throws IOException {
MavenVersionResolver versionResolver = spy(new MavenVersionResolver("https://repo1.maven.org/maven2", "org.sonarsource.sonarqube", "sonar-plugin-api"));
when(versionResolver.downloadVersions()).thenReturn(getMavenRepositoryVersion());
versionResolver.loadVersions();
@@ -75,6 +75,13 @@ MavenRepositoryVersion getMavenRepositoryVersion() {
versions.add("1.0");
versions.add("2.0");
versions.add("2.0.1");
+ versions.add("2.0.2");
+ versions.add("2.0.10");
+ versions.add("10.9.1");
+ versions.add("11.4.5");
+ versions.add("11.0.3");
+ versions.add("10.4.2");
+ versions.add("10.10.0");
versions.add("3.1");
versions.add("4.0");
versions.add("5.0");
@@ -88,8 +95,10 @@ MavenRepositoryVersion getMavenRepositoryVersion() {
private static Stream params() {
return Stream.of(
- Arguments.of("", "6.0"),
- Arguments.of("2.0", "2.0.1"),
+ Arguments.of("", "11.4.5"),
+ Arguments.of("10", "10.10.0"),
+ Arguments.of("5.", "5.0.1.9324"),
+ Arguments.of("2.0", "2.0.10"),
Arguments.of("5.0.1", "5.0.1.9324")
);
}