Skip to content
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
10 changes: 9 additions & 1 deletion .github/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@

buildscript {
repositories {
mavenCentral()
def mirrorUrl = project.findProperty("mavenCentralMirrorUrl")
boolean isCi = System.getenv("GITHUB_ACTIONS") != null || System.getenv("JENKINS_HOME") != null
def useMirror = isCi && mirrorUrl

if (!useMirror) {
mavenCentral()
} else {
maven { url mirrorUrl }
}
}
dependencies {
classpath group: 'org.yaml', name: 'snakeyaml', version: '2.2'
Expand Down
19 changes: 19 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Properties

val parentProperties = Properties().apply {
val file = file("../gradle.properties")
if (file.exists()) {
file.inputStream().use { load(it) }
}
}

val mavenCentralMirrorUrl = parentProperties.getProperty("mavenCentralMirrorUrl")
val isCi = System.getenv("GITHUB_ACTIONS") != null || System.getenv("JENKINS_HOME") != null
val useMirror = isCi && !mavenCentralMirrorUrl.isNullOrBlank()

// Plugins for configuring _this build_ of the module
plugins {
Expand All @@ -25,6 +37,13 @@ plugins {

// Define the set of repositories required to fetch and enable plugins.
repositories {
if (useMirror) {
logger.lifecycle("Running in CI. Mirroring Maven Central repositories via Google Maven Mirror for buildSrc.")
}

if (useMirror) {
maven { url = uri(mavenCentralMirrorUrl!!) }
}
maven { url = uri("https://plugins.gradle.org/m2/") }
maven {
url = uri("https://repo.spring.io/plugins-release/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@
package org.apache.beam.gradle

import org.gradle.api.Project

class Repositories {

static void register(Project project) {
def mirrorUrl = project.findProperty("mavenCentralMirrorUrl")
boolean isCi = System.getenv("GITHUB_ACTIONS") != null || System.getenv("JENKINS_HOME") != null
def useMirror = isCi && mirrorUrl

if (useMirror) {
project.logger.lifecycle("Running in CI. Mirroring Maven Central repositories via Google Maven Mirror.")
}

project.repositories {
maven { url project.offlineRepositoryRoot }
Expand All @@ -36,7 +42,11 @@ class Repositories {
return
}

mavenCentral()
if (!useMirror) {
mavenCentral()
} else {
maven { url mirrorUrl }
}
mavenLocal()

// For Confluent Kafka dependencies
Expand All @@ -60,15 +70,19 @@ class Repositories {
// Apply a plugin which provides the 'updateOfflineRepository' task that creates an offline
// repository. This offline repository satisfies all Gradle build dependencies and Java
// project dependencies. The offline repository is placed within $rootDir/offline-repo
// but can be overridden by specifying '-PofflineRepositoryRoot=/path/to/repo'.
// but can be overridden by specifying '-Pareas/offline-repo'.
// Note that parallel build must be disabled when executing 'updateOfflineRepository'
// by specifying '--no-parallel', see
// https://github.com/mdietrichstein/gradle-offline-dependencies-plugin/issues/3
project.apply plugin: "io.pry.gradle.offline_dependencies"
project.offlineDependencies {
repositories {
mavenLocal()
mavenCentral()
if (!useMirror) {
mavenCentral()
} else {
maven { url mirrorUrl }
}
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://repo.spring.io/plugins-release" }
maven { url "https://packages.confluent.io/maven/" }
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ flink_versions=1.17,1.18,1.19,1.20,2.0
spark_versions=3,4
# supported python versions
python_versions=3.10,3.11,3.12,3.13,3.14

# Maven Central fallback mirror URL
mavenCentralMirrorUrl=https://maven-central.storage-download.googleapis.com/maven2/
15 changes: 14 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@
import com.gradle.enterprise.gradleplugin.internal.extension.BuildScanExtensionWithHiddenFeatures

pluginManagement {
val mavenCentralMirrorUrl = settings.providers.gradleProperty("mavenCentralMirrorUrl").orNull
Comment thread
shunping marked this conversation as resolved.
val isCi = System.getenv("GITHUB_ACTIONS") != null || System.getenv("JENKINS_HOME") != null
val useMirror = isCi && !mavenCentralMirrorUrl.isNullOrBlank()

if (useMirror) {
logger.lifecycle("Running in CI. Mirroring Maven Central repositories via Google Maven Mirror.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log appears multiple times. Logging here once should suffice

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep them for now. We can remove them later if the infra problem is resolved.

}

repositories {
if (useMirror) {
maven { url = uri(mavenCentralMirrorUrl!!) }
}
gradlePluginPortal()
}
plugins {
id("org.javacc.javacc") version "4.0.3" // enable the JavaCC parser generator
}
Expand All @@ -28,7 +42,6 @@ plugins {
id("com.gradle.common-custom-user-data-gradle-plugin") version "2.6.0"
}


// JENKINS_HOME and BUILD_ID set automatically during Jenkins execution
val isJenkinsBuild = arrayOf("JENKINS_HOME", "BUILD_ID").all { System.getenv(it) != null }
// GITHUB_REPOSITORY and GITHUB_RUN_ID set automatically during Github Actions run
Expand Down
Loading