Skip to content

Commit

Permalink
Merge pull request #69 from gradle/cjohnson/parse-gradle-snapshot-dis…
Browse files Browse the repository at this point in the history
…tributions-urls

Properly parse `distributionUrl` for Gradle snapshot distributions
  • Loading branch information
clayburn authored Oct 28, 2022
2 parents f610541 + dad8c75 commit 6fc8159
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions release/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [FIX] - Properly parse `distributionUrl` for Gradle snapshot distributions
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public VersionInfo extractCurrentVersion(Path rootProjectDir) throws IOException
return extractBuildToolVersion(rootProjectDir,
"gradle/wrapper/gradle-wrapper.properties",
"distributionUrl", "distributionSha256Sum",
"distributions/gradle-(.*)-(bin|all).zip"
"distributions(?:-snapshots)?/gradle-(.*)-(bin|all).zip"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ class GradleBuildToolStrategyTest extends Specification {
e.message == "Could not extract version from property 'distributionUrl': unknown"
}

def "extract current Gradle version snapshot"() {
given:
createGradleWrapperProperties().text = standard('7.6-20221024231219+0000', 'bin', '789', true)

when:
def version = gradleBuildToolStrategy.extractCurrentVersion(workingDir)

then:
version.version == '7.6-20221024231219+0000'
version.checksum == Optional.of('789')
}

def "resolve release notes links"() {
given:
def version = '7.4.1'
Expand All @@ -74,12 +86,12 @@ class GradleBuildToolStrategyTest extends Specification {
releaseNotesLink == 'https://docs.gradle.org/7.4.1/release-notes.html'
}

private static String standard(String gradleVersion, String gradleDistro, String distributionChecksum) {
private static String standard(String gradleVersion, String gradleDistro, String distributionChecksum, boolean isSnapshot = false) {
"""
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=${distributionChecksum}
distributionUrl=https\\://services.gradle.org/distributions/gradle-${gradleVersion}-${gradleDistro}.zip
distributionUrl=https\\://services.gradle.org/distributions${isSnapshot ? "-snapshots": ""}/gradle-${gradleVersion}-${gradleDistro}.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
"""
Expand Down

0 comments on commit 6fc8159

Please sign in to comment.