Skip to content

Commit 9474479

Browse files
committed
Migrate from services.gradle.org to downloads.gradle.org
services.gradle.org now returns 301 redirects to downloads.gradle.org. Update all distribution and version API URLs to use the new canonical domain directly, avoiding unnecessary redirect hops. The old services.gradle.org domain is still accepted in existing wrapper properties files for backward compatibility.
1 parent a72ba76 commit 9474479

11 files changed

Lines changed: 84 additions & 89 deletions

File tree

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
3+
distributionUrl=https\://downloads.gradle.org/distributions/gradle-9.3.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

rewrite-core/src/test/resources/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
distributionBase=GRADLE_USER_HOME
1818
distributionPath=wrapper/dists
19-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
19+
distributionUrl=https\://downloads.gradle.org/distributions/gradle-7.6.1-bin.zip
2020
networkTimeout=10000
2121
zipStoreBase=GRADLE_USER_HOME
2222
zipStorePath=wrapper/dists

rewrite-gradle-tooling-model/model/src/test/java/org/openrewrite/gradle/toolingapi/AssertionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void customInitScript() {
9393
}
9494
9595
""";
96-
GradleWrapper gradleWrapper = GradleWrapper.create(URI.create("https://services.gradle.org/distributions/gradle-8.6-bin.zip"), null);
96+
GradleWrapper gradleWrapper = GradleWrapper.create(URI.create("https://downloads.gradle.org/distributions/gradle-8.6-bin.zip"), null);
9797
rewriteRun(
9898
spec -> spec.beforeRecipe(Assertions.withToolingApi(gradleWrapper, alternateInit)),
9999
//language=groovy

rewrite-gradle/src/main/java/org/openrewrite/gradle/UpdateGradleWrapper.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,26 @@
4646
import static org.openrewrite.gradle.util.GradleWrapper.*;
4747
import static org.openrewrite.internal.StringUtils.isBlank;
4848

49-
@RequiredArgsConstructor
50-
@FieldDefaults(level = AccessLevel.PRIVATE)
49+
@Value
5150
@EqualsAndHashCode(callSuper = false)
5251
public class UpdateGradleWrapper extends ScanningRecipe<UpdateGradleWrapper.GradleWrapperState> {
5352

54-
@Getter
55-
final String displayName = "Update Gradle wrapper";
53+
String displayName = "Update Gradle wrapper";
5654

57-
@Getter
58-
final String description = "Update the version of Gradle used in an existing Gradle wrapper. " +
59-
"Queries services.gradle.org to determine the available releases, but prefers the artifact repository URL " +
55+
String description = "Update the version of Gradle used in an existing Gradle wrapper. " +
56+
"Queries `downloads.gradle.org` to determine the available releases, but prefers the artifact repository URL " +
6057
"which already exists within the wrapper properties file. " +
61-
"If your artifact repository does not contain the same Gradle distributions as services.gradle.org, " +
58+
"If your artifact repository does not contain the same Gradle distributions as `downloads.gradle.org`, " +
6259
"then the recipe may suggest a version which is not available in your artifact repository.";
6360

64-
@Getter
6561
@Option(displayName = "New version",
6662
description = "An exact version number or node-style semver selector used to select the version number. " +
67-
"Defaults to the latest release available from services.gradle.org if not specified.",
63+
"Defaults to the latest release available from `downloads.gradle.org` if not specified.",
6864
example = "7.x",
6965
required = false)
7066
@Nullable
71-
final String version;
67+
String version;
7268

73-
@Getter
7469
@Option(displayName = "Distribution type",
7570
description = "The distribution of Gradle to use. \"bin\" includes Gradle binaries. " +
7671
"\"all\" includes Gradle binaries, source code, and documentation. " +
@@ -79,17 +74,15 @@ public class UpdateGradleWrapper extends ScanningRecipe<UpdateGradleWrapper.Grad
7974
required = false
8075
)
8176
@Nullable
82-
final String distribution;
77+
String distribution;
8378

84-
@Getter
8579
@Option(displayName = "Add if missing",
8680
description = "Add a Gradle wrapper, if it's missing. Defaults to `true`.",
8781
required = false)
8882
@Nullable
89-
final Boolean addIfMissing;
83+
Boolean addIfMissing;
9084

91-
@Getter
92-
@Option(example = "https://services.gradle.org/distributions/gradle-8.5-bin.zip",
85+
@Option(example = "https://downloads.gradle.org/distributions/gradle-8.5-bin.zip",
9386
displayName = "Wrapper URI",
9487
description = "The URI of the Gradle wrapper distribution.\n" +
9588
"Specifies a custom location from which to download the Gradle wrapper scripts (gradlew, gradlew.bat, etc.). This is useful for setting up the Gradle wrapper without relying on Gradle's official distribution services.\n\n" +
@@ -98,16 +91,15 @@ public class UpdateGradleWrapper extends ScanningRecipe<UpdateGradleWrapper.Grad
9891
"If the URI is inaccessible, the recipe will leave the existing wrapper files in the repository unchanged, as they are generally compatible with various Gradle versions.",
9992
required = false)
10093
@Nullable
101-
final String wrapperUri;
94+
String wrapperUri;
10295

103-
@Getter
10496
@Option(example = "29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda",
10597
displayName = "SHA-256 checksum",
10698
description = "The SHA-256 checksum of the Gradle distribution. " +
10799
"If specified, the recipe will add the checksum along with the custom distribution URL.",
108100
required = false)
109101
@Nullable
110-
final String distributionChecksum;
102+
String distributionChecksum;
111103

112104
@Override
113105
public String getInstanceNameSuffix() {
@@ -202,7 +194,7 @@ public Properties visitEntry(Properties.Entry entry, ExecutionContext ctx) {
202194
return entry;
203195
}
204196

205-
// Typical example: https://services.gradle.org/distributions/gradle-7.4-all.zip or https://company.com/repo/gradle-8.2-bin.zip
197+
// Typical example: https://downloads.gradle.org/distributions/gradle-7.4-all.zip or https://company.com/repo/gradle-8.2-bin.zip
206198
String currentDistributionUrl = entry.getValue().getText();
207199
acc.currentDistributionUrl = currentDistributionUrl;
208200

rewrite-gradle/src/main/java/org/openrewrite/gradle/util/GradleWrapper.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@
5151

5252
@Value
5353
public class GradleWrapper {
54+
private static final String GRADLE_DOWNLOADS_URL = "https://downloads.gradle.org";
55+
@SuppressWarnings("DeprecatedIsStillUsed")
56+
@Deprecated
5457
private static final String GRADLE_SERVICES_URL = "https://services.gradle.org";
55-
private static final String GRADLE_DISTRIBUTIONS_URL = GRADLE_SERVICES_URL + "/distributions";
56-
private static final String GRADLE_VERSIONS_ALL_URL = GRADLE_SERVICES_URL + "/versions/all";
58+
private static final String GRADLE_DISTRIBUTIONS_URL = GRADLE_DOWNLOADS_URL + "/distributions";
59+
private static final String GRADLE_VERSIONS_ALL_URL = GRADLE_DOWNLOADS_URL + "/versions/all";
5760
public static final String WRAPPER_JAR_LOCATION_RELATIVE_PATH = "gradle/wrapper/gradle-wrapper.jar";
5861
public static final String WRAPPER_PROPERTIES_LOCATION_RELATIVE_PATH = "gradle/wrapper/gradle-wrapper.properties";
5962
public static final String WRAPPER_SCRIPT_LOCATION_RELATIVE_PATH = "gradlew";
@@ -69,7 +72,7 @@ public class GradleWrapper {
6972

7073
/**
7174
* Construct a Gradle wrapper from a distribution type and version.
72-
* Used in contexts where services.gradle.org is available.
75+
* Used in contexts where downloads.gradle.org is available.
7376
*/
7477
public static GradleWrapper create(@Nullable String distributionTypeName, @Nullable String version, ExecutionContext ctx) {
7578
return create(null, distributionTypeName, version, ctx);
@@ -96,15 +99,15 @@ public static GradleWrapper create(@Nullable String currentDistributionUrl, @Nul
9699

97100
private static GradleVersion determineGradleVersion(@Nullable String currentDistributionUrl, @Nullable String version, VersionComparator versionComparator,
98101
DistributionType distributionType, ExecutionContext ctx) {
99-
if (currentDistributionUrl == null || currentDistributionUrl.startsWith(GRADLE_SERVICES_URL)) {
102+
if (currentDistributionUrl == null || currentDistributionUrl.startsWith(GRADLE_DOWNLOADS_URL) || currentDistributionUrl.startsWith(GRADLE_SERVICES_URL)) {
100103
// Only list all versions via services endpoint if a wildcard notation was requested or null, e.g. 8.x
101104
if (!(versionComparator instanceof ExactVersion)) {
102105
List<GradleVersion> allVersions = listAllPublicVersions(ctx);
103106
return allVersions.stream()
104107
.filter(v -> versionComparator.isValid(null, v.version))
105108
.filter(v -> v.distributionType == distributionType)
106109
.max((v1, v2) -> versionComparator.compare(null, v1.version, v2.version))
107-
.orElseThrow(() -> new IllegalStateException(String.format("Expected to find at least one Gradle wrapper version to select from %s.", GRADLE_SERVICES_URL)));
110+
.orElseThrow(() -> new IllegalStateException(String.format("Expected to find at least one Gradle wrapper version to select from %s.", GRADLE_DOWNLOADS_URL)));
108111
}
109112

110113
return new GradleVersion(version,
@@ -204,7 +207,7 @@ private static List<GradleVersion> listAllPrivateArtifactoryVersions(String arti
204207

205208
/**
206209
* Construct a Gradle wrapper from a URI.
207-
* Can be used in contexts where services.gradle.org, normally used for version lookups, is unavailable.
210+
* Can be used in contexts where downloads.gradle.org, normally used for version lookups, is unavailable.
208211
*/
209212
public static GradleWrapper create(URI fullDistributionUri, @SuppressWarnings("unused") ExecutionContext ctx) {
210213
String version = "";

rewrite-gradle/src/main/resources/META-INF/rewrite/examples.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,13 +715,13 @@ examples:
715715
- before: |
716716
distributionBase=GRADLE_USER_HOME
717717
distributionPath=wrapper/dists
718-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
718+
distributionUrl=https\://downloads.gradle.org/distributions/gradle-7.4-bin.zip
719719
zipStoreBase=GRADLE_USER_HOME
720720
zipStorePath=wrapper/dists
721721
after: |
722722
distributionBase=GRADLE_USER_HOME
723723
distributionPath=wrapper/dists
724-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
724+
distributionUrl=https\://downloads.gradle.org/distributions/gradle-7.4.2-bin.zip
725725
zipStoreBase=GRADLE_USER_HOME
726726
zipStorePath=wrapper/dists
727727
distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda
@@ -1281,13 +1281,13 @@ examples:
12811281
- before: |
12821282
distributionBase=GRADLE_USER_HOME
12831283
distributionPath=wrapper/dists
1284-
distributionUrl=https\\://services.gradle.org/distributions/gradle-7.4-all.zip
1284+
distributionUrl=https\\://downloads.gradle.org/distributions/gradle-7.4-all.zip
12851285
zipStoreBase=GRADLE_USER_HOME
12861286
zipStorePath=wrapper/dists
12871287
after: |
12881288
distributionBase=GRADLE_USER_HOME
12891289
distributionPath=wrapper/dists
1290-
~~>distributionUrl=https\\://services.gradle.org/distributions/gradle-7.4-all.zip
1290+
~~>distributionUrl=https\\://downloads.gradle.org/distributions/gradle-7.4-all.zip
12911291
zipStoreBase=GRADLE_USER_HOME
12921292
zipStorePath=wrapper/dists
12931293
path: gradle/wrapper/gradle-wrapper.properties

rewrite-gradle/src/main/resources/META-INF/rewrite/recipes.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The recipe will:
3434
* Preserve project dependencies unchanged
3535
3636
**Note:** If a version catalog already exists, the recipe will not modify it.",1,,Gradle,,
37-
maven,org.openrewrite:rewrite-gradle,org.openrewrite.gradle.UpdateGradleWrapper,Update Gradle wrapper,"Update the version of Gradle used in an existing Gradle wrapper. Queries services.gradle.org to determine the available releases, but prefers the artifact repository URL which already exists within the wrapper properties file. If your artifact repository does not contain the same Gradle distributions as services.gradle.org, then the recipe may suggest a version which is not available in your artifact repository.",1,,Gradle,"[{""name"":""version"",""type"":""String"",""displayName"":""New version"",""description"":""An exact version number or node-style semver selector used to select the version number. Defaults to the latest release available from services.gradle.org if not specified."",""example"":""7.x""},{""name"":""distribution"",""type"":""String"",""displayName"":""Distribution type"",""description"":""The distribution of Gradle to use. \""bin\"" includes Gradle binaries. \""all\"" includes Gradle binaries, source code, and documentation. Defaults to \""bin\""."",""valid"":[""bin"",""all""]},{""name"":""addIfMissing"",""type"":""Boolean"",""displayName"":""Add if missing"",""description"":""Add a Gradle wrapper, if it's missing. Defaults to `true`.""},{""name"":""wrapperUri"",""type"":""String"",""displayName"":""Wrapper URI"",""description"":""The URI of the Gradle wrapper distribution.\nSpecifies a custom location from which to download the Gradle wrapper scripts (gradlew, gradlew.bat, etc.). This is useful for setting up the Gradle wrapper without relying on Gradle's official distribution services.\n\nWhen this option is set, the version and distribution fields must not be specified — only one source of truth is allowed. The URI should point to a valid and reachable Gradle wrapper distribution (typically a .zip archive containing the wrapper files).\nThis is particularly helpful in environments where access to Gradle's central services is restricted or where custom Gradle wrapper setups are required.\nIf the URI is inaccessible, the recipe will leave the existing wrapper files in the repository unchanged, as they are generally compatible with various Gradle versions."",""example"":""https://services.gradle.org/distributions/gradle-8.5-bin.zip""},{""name"":""distributionChecksum"",""type"":""String"",""displayName"":""SHA-256 checksum"",""description"":""The SHA-256 checksum of the Gradle distribution. If specified, the recipe will add the checksum along with the custom distribution URL."",""example"":""29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda""}]",
37+
maven,org.openrewrite:rewrite-gradle,org.openrewrite.gradle.UpdateGradleWrapper,Update Gradle wrapper,"Update the version of Gradle used in an existing Gradle wrapper. Queries downloads.gradle.org to determine the available releases, but prefers the artifact repository URL which already exists within the wrapper properties file. If your artifact repository does not contain the same Gradle distributions as downloads.gradle.org, then the recipe may suggest a version which is not available in your artifact repository.",1,,Gradle,"[{""name"":""version"",""type"":""String"",""displayName"":""New version"",""description"":""An exact version number or node-style semver selector used to select the version number. Defaults to the latest release available from downloads.gradle.org if not specified."",""example"":""7.x""},{""name"":""distribution"",""type"":""String"",""displayName"":""Distribution type"",""description"":""The distribution of Gradle to use. \""bin\"" includes Gradle binaries. \""all\"" includes Gradle binaries, source code, and documentation. Defaults to \""bin\""."",""valid"":[""bin"",""all""]},{""name"":""addIfMissing"",""type"":""Boolean"",""displayName"":""Add if missing"",""description"":""Add a Gradle wrapper, if it's missing. Defaults to `true`.""},{""name"":""wrapperUri"",""type"":""String"",""displayName"":""Wrapper URI"",""description"":""The URI of the Gradle wrapper distribution.\nSpecifies a custom location from which to download the Gradle wrapper scripts (gradlew, gradlew.bat, etc.). This is useful for setting up the Gradle wrapper without relying on Gradle's official distribution services.\n\nWhen this option is set, the version and distribution fields must not be specified — only one source of truth is allowed. The URI should point to a valid and reachable Gradle wrapper distribution (typically a .zip archive containing the wrapper files).\nThis is particularly helpful in environments where access to Gradle's central services is restricted or where custom Gradle wrapper setups are required.\nIf the URI is inaccessible, the recipe will leave the existing wrapper files in the repository unchanged, as they are generally compatible with various Gradle versions."",""example"":""https://downloads.gradle.org/distributions/gradle-8.5-bin.zip""},{""name"":""distributionChecksum"",""type"":""String"",""displayName"":""SHA-256 checksum"",""description"":""The SHA-256 checksum of the Gradle distribution. If specified, the recipe will add the checksum along with the custom distribution URL."",""example"":""29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda""}]",
3838
maven,org.openrewrite:rewrite-gradle,org.openrewrite.gradle.UpgradeDependencyVersion,Upgrade Gradle dependency versions,"Upgrade the version of a dependency in a build.gradle file. Supports updating dependency declarations of various forms:
3939
* `String` notation: `""group:artifact:version""`
4040
* `Map` notation: `group: 'group', name: 'artifact', version: 'version'`

rewrite-gradle/src/main/resources/example.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,13 @@ examples:
556556
- before: |
557557
distributionBase=GRADLE_USER_HOME
558558
distributionPath=wrapper/dists
559-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
559+
distributionUrl=https\://downloads.gradle.org/distributions/gradle-7.4-bin.zip
560560
zipStoreBase=GRADLE_USER_HOME
561561
zipStorePath=wrapper/dists
562562
after: |
563563
distributionBase=GRADLE_USER_HOME
564564
distributionPath=wrapper/dists
565-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
565+
distributionUrl=https\://downloads.gradle.org/distributions/gradle-7.4.2-bin.zip
566566
zipStoreBase=GRADLE_USER_HOME
567567
zipStorePath=wrapper/dists
568568
distributionSha256Sum=29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda
@@ -1097,13 +1097,13 @@ examples:
10971097
- before: |
10981098
distributionBase=GRADLE_USER_HOME
10991099
distributionPath=wrapper/dists
1100-
distributionUrl=https\\://services.gradle.org/distributions/gradle-7.4-all.zip
1100+
distributionUrl=https\\://downloads.gradle.org/distributions/gradle-7.4-all.zip
11011101
zipStoreBase=GRADLE_USER_HOME
11021102
zipStorePath=wrapper/dists
11031103
after: |
11041104
distributionBase=GRADLE_USER_HOME
11051105
distributionPath=wrapper/dists
1106-
~~>distributionUrl=https\\://services.gradle.org/distributions/gradle-7.4-all.zip
1106+
~~>distributionUrl=https\\://downloads.gradle.org/distributions/gradle-7.4-all.zip
11071107
zipStoreBase=GRADLE_USER_HOME
11081108
zipStorePath=wrapper/dists
11091109
language: properties

0 commit comments

Comments
 (0)