From 35991d5eab0f3be67adc6bbaf9db743b94585674 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 4 Feb 2020 11:24:40 +0000 Subject: [PATCH] Adopt Gradle Enterprise Conventions Plugin Closes gh-20033 --- buildSrc/settings.gradle | 2 - gradle/build-cache-settings.gradle | 18 ------- gradle/build-scan-user-data.gradle | 80 ------------------------------ settings.gradle | 21 ++------ 4 files changed, 5 insertions(+), 116 deletions(-) delete mode 100644 gradle/build-cache-settings.gradle delete mode 100644 gradle/build-scan-user-data.gradle diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle index 07095fb096..b3efa07940 100644 --- a/buildSrc/settings.gradle +++ b/buildSrc/settings.gradle @@ -11,5 +11,3 @@ pluginManagement { } } } - -apply from: "${settingsDir}/../gradle/build-cache-settings.gradle" diff --git a/gradle/build-cache-settings.gradle b/gradle/build-cache-settings.gradle deleted file mode 100644 index 828d74f00c..0000000000 --- a/gradle/build-cache-settings.gradle +++ /dev/null @@ -1,18 +0,0 @@ -buildCache { - local { - enabled = true - } - remote(HttpBuildCache) { - enabled = true - url = "https://ge.spring.io/cache/" - def cacheUsername = System.getenv("GRADLE_ENTERPRISE_CACHE_USERNAME") - def cachePassword = System.getenv("GRADLE_ENTERPRISE_CACHE_PASSWORD") - if (cacheUsername && cachePassword) { - push = true - credentials { - username = cacheUsername - password = cachePassword - } - } - } -} diff --git a/gradle/build-scan-user-data.gradle b/gradle/build-scan-user-data.gradle deleted file mode 100644 index 8a09ed0515..0000000000 --- a/gradle/build-scan-user-data.gradle +++ /dev/null @@ -1,80 +0,0 @@ -tagOs() -tagJdk() -tagIde() -tagCiOrLocal() -addGitMetadata() - -void tagOs() { - gradleEnterprise.buildScan.tag System.getProperty("os.name") -} - -void tagJdk() { - gradleEnterprise.buildScan.tag "JDK-" + System.getProperty('java.specification.version') -} - -void tagIde() { - if (System.getProperty("idea.version")) { - gradleEnterprise.buildScan.tag "IntelliJ IDEA" - } else if (System.getProperty("eclipse.buildId")) { - gradleEnterprise.buildScan.tag "Eclipse" - } -} - -void tagCiOrLocal() { - gradleEnterprise.buildScan.tag(isCi() ? "CI" : "LOCAL") -} - -void addGitMetadata() { - gradleEnterprise.buildScan.background { - def gitCommitId = execAndGetStdout("git", "rev-parse", "--short=8", "--verify", "HEAD") - def gitBranchName = getBranch() - def gitStatus = execAndGetStdout("git", "status", "--porcelain") - - if(gitCommitId) { - def commitIdLabel = "Git Commit ID" - value commitIdLabel, gitCommitId - link "Git commit build scans", customValueSearchUrl([(commitIdLabel): gitCommitId]) - } - if (gitBranchName) { - tag gitBranchName - value "Git branch", gitBranchName - } - if (gitStatus) { - tag "dirty" - value "Git status", gitStatus - } - } -} - -boolean isCi() { - System.getenv("CI") -} - -String getBranch() { - def branch = System.getenv("BRANCH") - if (branch) { - return branch - } - return execAndGetStdout("git", "rev-parse", "--abbrev-ref", "HEAD") -} - -String execAndGetStdout(String... args) { - def stdout = new ByteArrayOutputStream() - exec { - commandLine(args) - standardOutput = stdout - } - return stdout.toString().trim() -} - -String customValueSearchUrl(Map search) { - def query = search.collect { name, value -> - "search.names=${encodeURL(name)}&search.values=${encodeURL(value)}" - }.join("&") - - "${gradleEnterprise.buildScan.server}/scans?${query}" -} - -String encodeURL(String url) { - URLEncoder.encode(url, "UTF-8") -} diff --git a/settings.gradle b/settings.gradle index 5671c837f1..922667e994 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,6 +2,9 @@ pluginManagement { repositories { mavenCentral() gradlePluginPortal() + maven { + url 'https://repo.spring.io/plugins-release' + } if (version.endsWith('BUILD-SNAPSHOT')) { maven { url "https://repo.spring.io/snapshot" } } @@ -19,24 +22,10 @@ pluginManagement { } plugins { - id "com.gradle.enterprise" version "3.1.1" -} - -apply from: "${rootDir}/gradle/build-scan-user-data.gradle" -gradleEnterprise { - buildScan { - captureTaskInputFiles = true - obfuscation { - ipAddresses { addresses -> addresses.collect { address -> "0.0.0.0"} } - } - publishAlways() - publishIfAuthenticated() - server = "https://ge.spring.io" - } + id "com.gradle.enterprise" version "3.1.1" + id "io.spring.gradle-enterprise-conventions" version "0.0.1" } -apply from: "${settingsDir}/gradle/build-cache-settings.gradle" - rootProject.name="spring-boot-build" include "spring-boot-project:spring-boot-dependencies"