From 3c923a113b98aa9c4ebacf5ceacf9b23160b1c99 Mon Sep 17 00:00:00 2001 From: Jacek Poreda Date: Mon, 29 Jan 2024 17:20:11 +0100 Subject: SONAR-21476 Fix public repository --- build.gradle | 33 ++++++++++++++++++++------------- settings.gradle | 20 +++++++++++++------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index 431cb948799..23d4fd0fa2f 100644 --- a/build.gradle +++ b/build.gradle @@ -73,21 +73,28 @@ allprojects { throw new GradleException('Invalid artifactoryUrl') } - maven { - if (artifactoryPassword) { - authentication { - header(HttpHeaderAuthentication) - } - credentials(HttpHeaderCredentials) { - name = "Authorization" - value = "Bearer $artifactoryPassword" - } - } else { - // Workaround for artifactory - // https://www.jfrog.com/jira/browse/RTFACT-13797 - repository = 'public' + if (artifactoryPassword) { + if (artifactoryUrl == '') { + throw new GradleException('Invalid artifactoryUrl') + } + maven { + authentication { + header(HttpHeaderAuthentication) + } + credentials(HttpHeaderCredentials) { + name = "Authorization" + value = "Bearer $artifactoryPassword" } url "${artifactoryUrl}/${repository}" + } + } else { + mavenCentral() + maven { + url 'https://jitpack.io' + } + maven { + url 'https://maven.codelibs.org/' + } } ivy { if (artifactoryUsername && artifactoryPassword) { diff --git a/settings.gradle b/settings.gradle index 1c1fa09fb5e..99c930014da 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,13 +1,19 @@ pluginManagement { repositories { + def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' + maven { - url 'https://repox.jfrog.io/repox/plugins.gradle.org/' - authentication { - header(HttpHeaderAuthentication) - } - credentials(HttpHeaderCredentials) { - name = "Authorization" - value = "Bearer $System.env.ARTIFACTORY_PRIVATE_PASSWORD" + if (artifactoryPassword) { + url 'https://repox.jfrog.io/repox/plugins.gradle.org/' + authentication { + header(HttpHeaderAuthentication) + } + credentials(HttpHeaderCredentials) { + name = "Authorization" + value = "Bearer $artifactoryPassword" + } + } else { + url 'https://plugins.gradle.org/m2/' } } } -- cgit v1.2.3