-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch versions from Gradle website to automatically pull in new versi…
…ons. Versions are filtered to be greater than 5.6 and to be a release version. To be able to keep our build matrix, the strategy there has to be changed to slice the set of discovered versions in a number of parts, and to select the part to run
- Loading branch information
1 parent
0ede3d4
commit 14fcf4b
Showing
5 changed files
with
183 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/integrationTest/java/eu/xenit/gradle/testrunner/versions/GradleVersionSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package eu.xenit.gradle.testrunner.versions; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import java.util.Comparator; | ||
import org.gradle.util.GradleVersion; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class GradleVersionSpec { | ||
private String version; | ||
private boolean snapshot; | ||
private boolean broken; | ||
private String rcFor; | ||
|
||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
public void setVersion(String version) { | ||
this.version = version; | ||
} | ||
|
||
public boolean isSnapshot() { | ||
return snapshot; | ||
} | ||
|
||
public void setSnapshot(boolean snapshot) { | ||
this.snapshot = snapshot; | ||
} | ||
|
||
public boolean isBroken() { | ||
return broken; | ||
} | ||
|
||
public void setBroken(boolean broken) { | ||
this.broken = broken; | ||
} | ||
|
||
public String getRcFor() { | ||
return rcFor; | ||
} | ||
|
||
public void setRcFor(String rcFor) { | ||
this.rcFor = rcFor; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/integrationTest/java/eu/xenit/gradle/testrunner/versions/VersionFetcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package eu.xenit.gradle.testrunner.versions; | ||
|
||
import com.fasterxml.jackson.core.JsonParseException; | ||
import com.fasterxml.jackson.databind.JsonMappingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.type.CollectionType; | ||
import java.io.IOException; | ||
import java.io.UncheckedIOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
import org.gradle.util.GradleVersion; | ||
|
||
public class VersionFetcher { | ||
private static List<GradleVersionSpec> fetchAllVersions() { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
|
||
try { | ||
CollectionType type = mapper.getTypeFactory().constructCollectionType(List.class, GradleVersionSpec.class); | ||
return mapper.readerFor(type).readValue(new URL("https://services.gradle.org/versions/all")); | ||
} catch (MalformedURLException | JsonMappingException | JsonParseException e) { | ||
throw new RuntimeException(e); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
} | ||
|
||
public static boolean isRelease(GradleVersionSpec versionSpec) { | ||
GradleVersion gradleVersion = GradleVersion.version(versionSpec.getVersion()); | ||
return !versionSpec.isSnapshot() && versionSpec.getRcFor().isEmpty() && Objects.equals(gradleVersion.getBaseVersion(), gradleVersion); | ||
} | ||
|
||
public static boolean isBroken(GradleVersionSpec versionSpec) { | ||
return versionSpec.isBroken(); | ||
} | ||
|
||
public static Predicate<GradleVersionSpec> greaterThan(String version) { | ||
return versionSpec -> GradleVersion.version(versionSpec.getVersion()).compareTo(GradleVersion.version(version)) > 0; | ||
} | ||
|
||
public static boolean firstPointRelease(GradleVersionSpec versionSpec) { | ||
return GradleVersion.version(versionSpec.getVersion()).getBaseVersion().getVersion().endsWith(".0"); | ||
} | ||
|
||
public static Stream<GradleVersionSpec> fetchVersions() { | ||
return fetchAllVersions() | ||
.stream() | ||
.filter(((Predicate<? super GradleVersionSpec>) GradleVersionSpec::isBroken).negate()); | ||
} | ||
|
||
} |