shunping commented on code in PR #38586:
URL: https://github.com/apache/beam/pull/38586#discussion_r3282279740


##########
settings.gradle.kts:
##########
@@ -18,6 +18,33 @@
 import 
com.gradle.enterprise.gradleplugin.internal.extension.BuildScanExtensionWithHiddenFeatures
 
 pluginManagement {
+    val isMavenAccessible = try {
+        val connection = 
java.net.URL("https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.pom";).openConnection()
 as java.net.HttpURLConnection
+        connection.requestMethod = "GET"
+        connection.setRequestProperty("User-Agent", "Gradle")
+        connection.connectTimeout = 2000
+        connection.readTimeout = 2000
+        connection.useCaches = false
+        connection.responseCode == 200
+    } catch (e: Exception) {
+        false
+    }
+    val mavenCentralMirrorUrl = 
"https://maven-central.storage-download.googleapis.com/maven2/";
+
+    if (isMavenAccessible) {
+        logger.lifecycle("Maven Central is accessible. Using default 
repositories for settings plugins.")
+    } else {
+        logger.lifecycle("Maven Central is not accessible. Falling back to 
Google Maven Mirror for settings plugins.")
+    }
+
+    repositories {
+        if (isMavenAccessible) {
+            gradlePluginPortal()
+        } else {
+            maven { url = uri(mavenCentralMirrorUrl) }
+            gradlePluginPortal()
+        }

Review Comment:
   Done.



##########
buildSrc/build.gradle.kts:
##########
@@ -25,7 +52,12 @@ plugins {
 
 // Define the set of repositories required to fetch and enable plugins.
 repositories {
-  maven { url = uri("https://plugins.gradle.org/m2/";) }
+  if (isMavenAccessible) {
+    maven { url = uri("https://plugins.gradle.org/m2/";) }
+  } else {
+    maven { url = uri(mavenCentralMirrorUrl) }
+    maven { url = uri("https://plugins.gradle.org/m2/";) }
+  }

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to