Skip to content

Commit

Permalink
Allow overriding the default Gradle library repository through a new …
Browse files Browse the repository at this point in the history
…system property called `org.gradle.internal.gradle.libs.repo.override` (previously overriding was only possible through the `GRADLE_LIBS_REPO_OVERRIDE` environment variable).

The system property can be more useful because it can be defined in the build itself (either through gradle.properties or programmatically)

Signed-off-by: akiraly <kiralyattila.hu@gmail.com>
  • Loading branch information
akiraly committed Oct 15, 2023
1 parent 3051dae commit 8fe68af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ dependencies {
@Requires(IntegTestPreconditions.IsDaemonExecutor)
def "does not download gradleApi() sources when sources download is disabled"() {
given:
executer.withEnvironmentVars('GRADLE_REPO_OVERRIDE': "$server.uri/")
executer.withEnvironmentVars('GRADLE_LIBS_REPO_OVERRIDE': "$server.uri/")
buildScript """
apply plugin: "java"
Expand All @@ -336,7 +336,7 @@ dependencies {
@Requires(IntegTestPreconditions.IsDaemonExecutor)
def "does not download gradleApi() sources when offline"() {
given:
executer.withEnvironmentVars('GRADLE_REPO_OVERRIDE': "$server.uri/")
executer.withEnvironmentVars('GRADLE_LIBS_REPO_OVERRIDE': "$server.uri/")
buildScript """
apply plugin: "java"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class DefaultGradleApiSourcesResolver implements GradleApiSourcesResolver

private static final String GRADLE_LIBS_REPO_URL = "https://repo.gradle.org/gradle/list/libs-releases";
private static final String GRADLE_LIBS_REPO_OVERRIDE_VAR = "GRADLE_LIBS_REPO_OVERRIDE";
private static final String GRADLE_LIBS_REPO_OVERRIDE_PROPERTY = "org.gradle.internal.gradle.libs.repo.override";
private static final Pattern FILE_NAME_PATTERN = Pattern.compile("(groovy(-.+?)?)-(\\d.+?)\\.jar");

private final DetachedResolver resolver;
Expand Down Expand Up @@ -82,6 +83,10 @@ private MavenArtifactRepository addGradleLibsRepository() {

private static String gradleLibsRepoUrl() {
String repoOverride = System.getenv(GRADLE_LIBS_REPO_OVERRIDE_VAR);
if (repoOverride != null) {
return repoOverride;
}
repoOverride = System.getProperty(GRADLE_LIBS_REPO_OVERRIDE_PROPERTY);
return repoOverride != null ? repoOverride : GRADLE_LIBS_REPO_URL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ Specifies the JDK installation directory to use for the client VM.
This VM is also used for the daemon unless a different one is specified in a Gradle properties file with `org.gradle.java.home`.

`GRADLE_LIBS_REPO_OVERRIDE`::
Overrides for the default Gradle library repository.
Overrides for the default Gradle library repository. The default Gradle library repository can also be overridden
with the `org.gradle.internal.gradle.libs.repo.override` system property.
+
Can be used to specify a default Gradle repository URL in `org.gradle.plugins.ide.internal.resolver`.
+
Expand Down

0 comments on commit 8fe68af

Please sign in to comment.