Bug 1876335 - use GRADLE_MAVEN_REPOSITORIES in more places. r=owlish,geckoview-reviewers,nalexander,tthibaud,android-reviewers

To ensure that we can build offline, we need to prevent gradle from
going through remote maven repos directly.

That means also overriding the default plugin repository
(plugins.gradle.org) in the `pluginManagement` section.

Differential Revision: https://phabricator.services.mozilla.com/D201497
This commit is contained in:
Gabriel Luong 2024-01-18 15:38:47 +01:00
parent d3ac4afbe4
commit 10bf459698
28 changed files with 258 additions and 283 deletions

View file

@ -9,12 +9,7 @@ import static org.gradle.api.tasks.testing.TestResult.ResultType
buildscript {
repositories {
if (!System.env.MOZ_AUTOMATION && gradle.mozconfig.substs.MOZ_ARTIFACT_BUILDS) {
mavenLocal()
}
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
rootProject.logger.lifecycle("Adding GRADLE_MAVEN_REPOSITORIES ${repository}")
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
@ -22,26 +17,6 @@ buildscript {
}
}
}
if (project.hasProperty("googleRepo")) {
maven {
name "Google"
url project.property("googleRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
google()
}
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral()
}
}
dependencies {
@ -65,12 +40,7 @@ plugins {
allprojects {
repositories {
if (!System.env.MOZ_AUTOMATION && gradle.mozconfig.substs.MOZ_ARTIFACT_BUILDS) {
mavenLocal()
}
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
rootProject.logger.lifecycle("Adding GRADLE_MAVEN_REPOSITORIES ${repository}")
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
@ -78,38 +48,6 @@ allprojects {
}
}
}
if (project.hasProperty("googleRepo")) {
maven {
name "Google"
url project.property("googleRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
google()
}
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral()
}
maven {
name "Mozilla"
url "https://maven.mozilla.org/maven2"
}
if (ExtraRepositories.mozillaStaging) {
maven {
name "Mozilla Staging"
url "https://maven-default.stage.mozaws.net/maven2"
}
}
}
}

View file

@ -4,8 +4,13 @@
buildscript {
repositories {
maven {
url "https://maven.mozilla.org/maven2"
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}

View file

@ -4,11 +4,14 @@
buildscript {
repositories {
maven {
url "https://maven.mozilla.org/maven2"
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
gradlePluginPortal()
}
dependencies {

View file

@ -4,14 +4,12 @@
buildscript {
repositories {
maven {
url "https://maven.mozilla.org/maven2"
}
if (ExtraRepositories.mozillaStaging) {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
name "Mozilla Staging"
url "https://maven-default.stage.mozaws.net/maven2"
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}

View file

@ -3,11 +3,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
buildscript {
repositories {
maven {
url "https://maven.mozilla.org/maven2"
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
gradlePluginPortal()
}
dependencies {
classpath ComponentsDependencies.plugin_serialization

View file

@ -7,7 +7,14 @@ plugins {
}
repositories {
mavenCentral()
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
gradlePlugin {

View file

@ -3,3 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Prevents gradle builds from looking for a root settings.gradle
pluginManagement {
apply from: file('../../../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
}

View file

@ -7,15 +7,14 @@ plugins {
}
repositories {
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
} else {
mavenCentral()
}
}
gradlePlugin {

View file

@ -3,3 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Prevents gradle builds from looking for a root settings.gradle
pluginManagement {
apply from: file('../../../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
}

View file

@ -7,15 +7,14 @@ plugins {
}
repositories {
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
} else {
mavenCentral()
}
}
dependencies {

View file

@ -5,6 +5,19 @@
// Prevents gradle builds from looking for a root settings.gradle
pluginManagement {
apply from: file('../../../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
includeBuild("../dependencies")
}

View file

@ -4,8 +4,13 @@
buildscript {
repositories {
maven {
url "https://maven.mozilla.org/maven2"
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
dependencies {

View file

@ -4,8 +4,13 @@
buildscript {
repositories {
maven {
url "https://maven.mozilla.org/maven2"
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
dependencies {

View file

@ -3,6 +3,19 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pluginManagement {
apply from: file('../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
includeBuild("plugins/dependencies")
includeBuild("plugins/publicsuffixlist")
}

View file

@ -10,69 +10,11 @@ import java.nio.file.StandardCopyOption
buildscript {
// This logic is duplicated in the allprojects block: I don't know how to fix that.
repositories {
if (!System.env.MOZ_AUTOMATION && gradle.mozconfig.substs.MOZ_ARTIFACT_BUILDS) {
mavenLocal()
}
maven {
name "Mozilla Nightly"
url "https://nightly.maven.mozilla.org/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
maven {
name "Mozilla"
url "https://maven.mozilla.org/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
if (ExtraRepositories.mozillaStaging) {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
name "Mozilla Staging"
url "https://maven-default.stage.mozaws.net/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
}
if (project.hasProperty("googleRepo")) {
maven {
name "Google"
allowInsecureProtocol true // Local Nexus in CI uses HTTP
url project.property("googleRepo")
}
} else {
google() {
content {
// Improve performance: only check google maven for google deps.
includeGroupByRegex RepoMatching.androidx
includeGroupByRegex RepoMatching.comAndroid
includeGroupByRegex RepoMatching.comGoogle
}
}
}
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral() {
content {
// Improve security: don't search deps with known repos.
excludeGroupByRegex RepoMatching.mozilla
excludeGroupByRegex RepoMatching.androidx
excludeGroupByRegex RepoMatching.comAndroid
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
@ -109,69 +51,11 @@ plugins {
allprojects {
// This logic is duplicated in the buildscript block: I don't know how to fix that.
repositories {
if (!System.env.MOZ_AUTOMATION && gradle.mozconfig.substs.MOZ_ARTIFACT_BUILDS) {
mavenLocal()
}
maven {
name "Mozilla Nightly"
url "https://nightly.maven.mozilla.org/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
maven {
name "Mozilla"
url "https://maven.mozilla.org/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
if (ExtraRepositories.mozillaStaging) {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
name "Mozilla Staging"
url "https://maven-default.stage.mozaws.net/maven2"
content {
// Improve performance: only check moz maven for mozilla deps.
includeGroupByRegex RepoMatching.mozilla
}
}
}
if (project.hasProperty("googleRepo")) {
maven {
name "Google"
url project.property("googleRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
google() {
content {
// Improve performance: only check google maven for google deps.
includeGroupByRegex RepoMatching.androidx
includeGroupByRegex RepoMatching.comAndroid
includeGroupByRegex RepoMatching.comGoogle
}
}
}
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
}
} else {
mavenCentral() {
content {
// Improve security: don't search deps with known repos.
excludeGroupByRegex RepoMatching.mozilla
excludeGroupByRegex RepoMatching.androidx
excludeGroupByRegex RepoMatching.comAndroid
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}

View file

@ -6,15 +6,14 @@ apply plugin: 'java-library'
apply plugin: 'kotlin'
repositories {
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
} else {
mavenCentral()
}
}
dependencies {

View file

@ -7,15 +7,14 @@ plugins {
}
repositories {
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
} else {
mavenCentral()
}
}
dependencies {

View file

@ -3,3 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Prevents gradle builds from looking for a root settings.gradle
pluginManagement {
apply from: file('../../../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
}

View file

@ -7,15 +7,14 @@ plugins {
}
repositories {
if (project.hasProperty("centralRepo")) {
maven {
name "MavenCentral"
url project.property("centralRepo")
allowInsecureProtocol true // Local Nexus in CI uses HTTP
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
} else {
mavenCentral()
}
}
gradlePlugin {

View file

@ -3,3 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Prevents gradle builds from looking for a root settings.gradle
pluginManagement {
apply from: file('../../../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
}

View file

@ -3,6 +3,19 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pluginManagement {
apply from: file('../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
includeBuild("../android-components/plugins/publicsuffixlist")
includeBuild("../android-components/plugins/dependencies")
includeBuild("../android-components/plugins/config")

View file

@ -5,24 +5,12 @@ import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
buildscript {
repositories {
if (!System.env.MOZ_AUTOMATION && gradle.mozconfig.substs.MOZ_ARTIFACT_BUILDS) {
mavenLocal()
}
google()
mavenCentral()
maven {
// We will always need this repository for retrieving stable dependencies (like Glean).
url "https://maven.mozilla.org/maven2"
}
maven {
url "https://nightly.maven.mozilla.org/maven2"
}
if (ExtraRepositories.mozillaStaging) {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
name "Mozilla Staging"
url "https://maven-default.stage.mozaws.net/maven2"
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
@ -92,23 +80,12 @@ tasks.withType(DetektCreateBaselineTask).configureEach() {
allprojects {
repositories {
if (!System.env.MOZ_AUTOMATION && gradle.mozconfig.substs.MOZ_ARTIFACT_BUILDS) {
mavenLocal()
}
google()
mavenCentral()
maven {
url "https://nightly.maven.mozilla.org/maven2"
}
maven {
url "https://maven.mozilla.org/maven2"
}
if (ExtraRepositories.mozillaStaging) {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
name "Mozilla Staging"
url "https://maven-default.stage.mozaws.net/maven2"
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}

View file

@ -7,7 +7,14 @@ plugins {
}
repositories {
mavenCentral()
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
gradlePlugin {

View file

@ -3,3 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Prevents gradle builds from looking for a root settings.gradle
pluginManagement {
apply from: file('../../../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
}

View file

@ -3,6 +3,19 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pluginManagement {
apply from: file('../gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
includeBuild("../android-components/plugins/publicsuffixlist")
includeBuild("../android-components/plugins/dependencies")
includeBuild("../android-components/plugins/config")

View file

@ -11,6 +11,10 @@ apply from: file('./mach_env.gradle')
logger.lifecycle("mozconfig.gradle> Loading mach environment into a gradle extension property")
if (!ext.hasProperty("topsrcdir")) {
ext.topsrcdir = file(buildscript.getSourceFile()).getParentFile().getParentFile().getParentFile().getParentFile().absolutePath
}
def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
if (System.env.GRADLE_MACH_PYTHON) {
commandLine.addAll(0, [System.env.GRADLE_MACH_PYTHON])

View file

@ -5,8 +5,17 @@
import org.yaml.snakeyaml.Yaml
buildscript {
apply from: file('./gradle/mozconfig.gradle')
repositories {
mavenCentral()
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
dependencies {

View file

@ -1,4 +1,17 @@
pluginManagement {
apply from: file('mobile/android/gradle/mozconfig.gradle')
repositories {
gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
maven {
url repository
if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
allowInsecureProtocol = true
}
}
}
}
includeBuild("${rootProject.projectDir.absolutePath}/mobile/android/android-components/plugins/config")
includeBuild("${rootProject.projectDir.absolutePath}/mobile/android/android-components/plugins/dependencies")
includeBuild("${rootProject.projectDir.absolutePath}/mobile/android/android-components/plugins/publicsuffixlist")