1515 * See the License for the specific language governing permissions and
1616 * limitations under the License.
1717 */
18- import java.net.HttpURLConnection
19- import java.net.URL
20-
21- fun checkMavenCentralAccessibility (): Boolean {
22- val testUrl = " https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.pom"
23- val accessible = try {
24- val connection = URL (testUrl).openConnection() as HttpURLConnection
25- connection.requestMethod = " GET"
26- connection.setRequestProperty(" User-Agent" , " Gradle" )
27- connection.connectTimeout = 2000
28- connection.readTimeout = 2000
29- connection.useCaches = false
30- connection.responseCode == 200
31- } catch (e: Exception ) {
32- false
33- }
34-
35- if (accessible) {
36- logger.lifecycle(" Maven Central is accessible. Using default repositories for buildSrc." )
37- } else {
38- logger.lifecycle(" Maven Central is not accessible. Falling back to Google Maven Mirror for buildSrc." )
39- }
40- return accessible
41- }
42-
43- val isMavenAccessible = checkMavenCentralAccessibility()
18+ val isMavenAccessible = System .getProperty(" beam.maven.accessible" )?.toBoolean() ? : true
4419val mavenCentralMirrorUrl = " https://maven-central.storage-download.googleapis.com/maven2/"
4520
4621// Plugins for configuring _this build_ of the module
@@ -55,6 +30,7 @@ repositories {
5530 if (isMavenAccessible) {
5631 maven { url = uri(" https://plugins.gradle.org/m2/" ) }
5732 } else {
33+ logger.lifecycle(" Maven Central is not accessible. Falling back to Google Maven Mirror for buildSrc." )
5834 maven { url = uri(mavenCentralMirrorUrl) }
5935 maven { url = uri(" https://plugins.gradle.org/m2/" ) }
6036 }
0 commit comments