Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly parse distributionUrl for Gradle snapshot distributions #69

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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