From ee0ab1c946cb27faba5397e2dd8992f7c40329ac Mon Sep 17 00:00:00 2001 From: Mattias Reichel Date: Wed, 13 Nov 2024 21:59:39 +0100 Subject: [PATCH] ci: Update `groovy-joint-workflow` to use `mavenLocal()` (#543) Also update to develocity gradle plugin and related change to DEVELOCITY_* env vars. --- .github/workflows/gradle.yml | 12 +- .github/workflows/groovy-joint-workflow.yml | 206 +++++++++----------- .github/workflows/release.yml | 16 +- build.gradle | 26 +-- settings.gradle | 30 +-- 5 files changed, 147 insertions(+), 143 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index b2590fd0f6..13e0f81a90 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -25,7 +25,9 @@ jobs: - name: "ðŸ”Ļ Run Build" id: build env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} run: ./gradlew build --refresh-dependencies - name: "ðŸ“Ī Upload Artifact" if: success() @@ -51,7 +53,9 @@ jobs: uses: gradle/actions/setup-gradle@v4 - name: "ðŸ“Ī Publish Snapshot to repo.grails.org" env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} run: ./gradlew publish @@ -74,7 +78,9 @@ jobs: - name: "ðŸ”Ļ Build Docs" id: docs env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} run: ./gradlew docs --refresh-dependencies - name: "ðŸ“Ī Publish docs to Github Pages" if: steps.docs.outcome == 'success' diff --git a/.github/workflows/groovy-joint-workflow.yml b/.github/workflows/groovy-joint-workflow.yml index 79145e1b5c..a92e70766b 100644 --- a/.github/workflows/groovy-joint-workflow.yml +++ b/.github/workflows/groovy-joint-workflow.yml @@ -1,22 +1,4 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: "Grails Joint Validation Build" -# GROOVY_2_5_X == Grails 4.0.x -# GROOVY_3_0_X == grails master -# Groovy master branch does not map to any due to changed package names. +name: "Groovy Joint Validation Build" on: push: branches: @@ -27,134 +9,136 @@ on: workflow_dispatch: permissions: contents: read -env: - CI_GROOVY_VERSION: jobs: build_groovy: - strategy: - fail-fast: true runs-on: ubuntu-latest outputs: groovyVersion: ${{ steps.groovy-version.outputs.value }} steps: - - name: Set up JDK + - name: "☕ïļ Setup JDK" uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: 17 - - name: Cache local Maven repository & Groovy + - name: "🗄ïļ Cache local Maven repository" uses: actions/cache@v4 with: - path: | - ~/groovy - ~/.m2/repository - key: cache-local-groovy-maven-${{ github.sha }} - - name: Checkout Groovy 4_0_X (Grails 7 and later) - run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_4_0_X --single-branch - - name: Set CI_GROOVY_VERSION for Grails + path: ~/.m2/repository + key: cache-local-maven-${{ github.sha }} + - name: "ðŸ“Ĩ Checkout this project to fetch Gradle Plugin versions it uses" + uses: actions/checkout@v4 + with: + sparse-checkout-cone-mode: false + sparse-checkout: settings.gradle + - name: "📝 Store the Gradle Plugin versions used in this project" + id: gradle-plugin-versions + run: | + DEVELOCITY_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.develocity\"\|'"'com.gradle.develocity'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:]) + COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.common-custom-user-data-gradle-plugin\"\|'"'com.gradle.common-custom-user-data-gradle-plugin'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:]) + echo "Project uses Develocity Plugin version: $DEVELOCITY_PLUGIN_VERSION" + echo "Project uses Common Custom User Data Plugin version: $COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION" + echo "develocity_plugin_version=$DEVELOCITY_PLUGIN_VERSION" >> $GITHUB_OUTPUT + echo "common_custom_user_data_plugin_version=$COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION" >> $GITHUB_OUTPUT + rm settings.gradle + - name: "ðŸ“Ĩ Checkout Groovy 4_0_X (Grails 7 and later)" + run: git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_4_0_X --single-branch + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "📝 Store Groovy version to use when building this project" id: groovy-version run: | - cd ../groovy - echo "CI_GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_ENV - echo "value=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_OUTPUT - - name: Prepare Develocity Setup 1 - id: develocity_conf_1 + cd groovy + GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]') + echo "Groovy version $GROOVY_VERSION stored" + echo "value=$GROOVY_VERSION" >> $GITHUB_OUTPUT + - name: "🐘 Configure Gradle Plugins (Step 1/3)" + id: develocity-conf-1 run: | echo "VALUE<> $GITHUB_OUTPUT echo "plugins { " >> $GITHUB_OUTPUT - echo " id 'com.gradle.enterprise' version '3.15.1'" >> $GITHUB_OUTPUT - echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.11.3'" >> $GITHUB_OUTPUT + echo " id 'com.gradle.develocity' version '${{ steps.gradle-plugin-versions.outputs.develocity_plugin_version }}'" >> $GITHUB_OUTPUT + echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '${{ steps.gradle-plugin-versions.outputs.common_custom_user_data_plugin_version }}'" >> $GITHUB_OUTPUT echo "}" >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - - name: Prepare Develocity Setup 2 - id: develocity_conf_2 + - name: "🐘 Configure Gradle Plugins (Step 2/3)" + id: develocity-conf-2 run: | echo "VALUE<> $GITHUB_OUTPUT - echo "gradleEnterprise {" >> $GITHUB_OUTPUT - echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT - echo " buildScan {" >> $GITHUB_OUTPUT - echo " publishAlways()" >> $GITHUB_OUTPUT - echo " publishIfAuthenticated()" >> $GITHUB_OUTPUT - echo " uploadInBackground = System.getenv('CI') == null" >> $GITHUB_OUTPUT - echo " capture {" >> $GITHUB_OUTPUT - echo " taskInputFiles = true" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo "}" >> $GITHUB_OUTPUT + echo "def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null" >> $GITHUB_OUTPUT + echo "def isBuildCacheAuthenticated =" >> $GITHUB_OUTPUT + echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null &&" >> $GITHUB_OUTPUT + echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null" >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT - echo "buildCache {" >> $GITHUB_OUTPUT - echo " local { enabled = System.getenv('CI') != 'true' }" >> $GITHUB_OUTPUT - echo " remote(HttpBuildCache) {" >> $GITHUB_OUTPUT - echo " push = System.getenv('CI') == 'true'" >> $GITHUB_OUTPUT - echo " enabled = true" >> $GITHUB_OUTPUT - echo " url = 'https://ge.grails.org/cache/'" >> $GITHUB_OUTPUT - echo " credentials {" >> $GITHUB_OUTPUT - echo " username = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER')" >> $GITHUB_OUTPUT - echo " password = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY')" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo " }" >> $GITHUB_OUTPUT - echo "}" >> $GITHUB_OUTPUT + echo "develocity {" >> $GITHUB_OUTPUT + echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT + echo " buildScan {" >> $GITHUB_OUTPUT + echo " publishing.onlyIf { isAuthenticated }" >> $GITHUB_OUTPUT + echo " uploadInBackground = false" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo "}" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "buildCache {" >> $GITHUB_OUTPUT + echo " local { enabled = false }" >> $GITHUB_OUTPUT + echo " remote(develocity.buildCache) {" >> $GITHUB_OUTPUT + echo " push = isBuildCacheAuthenticated" >> $GITHUB_OUTPUT + echo " enabled = true" >> $GITHUB_OUTPUT + echo " usernameAndPassword(" >> $GITHUB_OUTPUT + echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: ''," >> $GITHUB_OUTPUT + echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: ''" >> $GITHUB_OUTPUT + echo " )" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo "}" >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - - name: Develocity Set-up + - name: "🐘 Configure Gradle Plugins (step 3/3)" run: | - cd ../groovy + cd groovy # Delete existing plugins from settings.gradle file sed -i '32,37d' settings.gradle - # Add Gradle Enterprise set-up related configuration after line no 31 in settings.gradle - echo "${{ steps.develocity_conf_1.outputs.value }}" | sed -i -e "31r /dev/stdin" settings.gradle + # Add Develocity setup related configuration after line no 31 in settings.gradle + echo "${{ steps.develocity-conf-1.outputs.value }}" | sed -i -e "31r /dev/stdin" settings.gradle # Delete existing buildCache configuration from gradle/build-scans.gradle file sed -i '23,46d' gradle/build-scans.gradle - # Add Gradle Enterprise set-up related configuration after line no 22 in gradle/build-scans.gradle - echo "${{ steps.develocity_conf_2.outputs.value }}" | sed -i -e "22r /dev/stdin" gradle/build-scans.gradle - - name: Build and install groovy (no docs) - uses: gradle/gradle-build-action@v3 + # Add Develocity setup related configuration after line no 22 in gradle/build-scans.gradle + echo "${{ steps.develocity-conf-2.outputs.value }}" | sed -i -e "22r /dev/stdin" gradle/build-scans.gradle + - name: "ðŸ”Ļ Publish Groovy to local maven repository (no docs)" env: - GRADLE_SCANS_ACCEPT: yes - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - with: - build-root-directory: ../groovy - arguments: | - install - -x groovydoc - -x javadoc - -x javadocAll - -x groovydocAll - -x asciidoc - -x docGDK - build_gsp: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: | + cd groovy + ./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK + + build_project: needs: [build_groovy] - strategy: - fail-fast: true runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up JDK + - name: "ðŸ“Ĩ Checkout project" + uses: actions/checkout@v4 + - name: "☕ïļ Setup JDK" uses: actions/setup-java@v4 with: - distribution: temurin + distribution: liberica java-version: 17 - - name: Cache local Maven repository & Groovy + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "🗄ïļ Restore local Maven repository from cache" uses: actions/cache@v4 with: - path: | - ~/groovy - ~/.m2/repository - key: cache-local-groovy-maven-${{ github.sha }} - - name: Set CI_GROOVY_VERSION for Grails - run: | - echo "CI_GROOVY_VERSION=${{needs.build_groovy.outputs.groovyVersion}}" >> $GITHUB_ENV - - name: Build GSP - id: build_gsp - uses: gradle/gradle-build-action@v3 + path: ~/.m2/repository + key: cache-local-maven-${{ github.sha }} + - name: "ðŸŠķ Add mavenLocal repository to build" + run: sed -i 's|// mavenLocal() // Keep|mavenLocal() // Keep|' build.gradle + - name: "ðŸ”Ļ Build and test project using the locally built Groovy snapshot" env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - with: - arguments: | - build - -x groovydoc + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew build + -PgroovyVersion=${{needs.build_groovy.outputs.groovyVersion}} + -x groovydoc \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75381cda55..ef9ab90977 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,9 @@ jobs: with: arguments: assemble env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - name: Upload Distribution if: success() uses: actions/upload-artifact@v4 @@ -49,7 +51,9 @@ jobs: id: publish uses: gradle/gradle-build-action@v3 env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} @@ -75,7 +79,9 @@ jobs: - name: Nexus Staging Close And Release uses: gradle/gradle-build-action@v3 env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} @@ -112,7 +118,9 @@ jobs: with: arguments: docs env: - GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - name: Publish to Github Pages if: success() uses: micronaut-projects/github-pages-deploy-action@grails diff --git a/build.gradle b/build.gradle index e8557a233e..b6e5ee8205 100644 --- a/build.gradle +++ b/build.gradle @@ -12,17 +12,11 @@ buildscript { } ext { - groovyVersion = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion isCiBuild = System.getenv().get("TRAVIS") == 'true' || (System.getenv().get("CI") as Boolean) isSnapshot = project.projectVersion.endsWith('-SNAPSHOT') isReleaseVersion = !isSnapshot } -repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } -} - group = "org.grails" version project.projectVersion @@ -35,6 +29,19 @@ ext.set('signing.password', project.findProperty('signing.password') ?: System.g apply plugin: 'idea' +allprojects { + repositories { + mavenCentral() + maven { url = 'https://repo.grails.org/grails/core' } + // mavenLocal() // Keep, this will be uncommented and used by CI (groovy-joint-workflow) + if (groovyVersion?.endsWith('-SNAPSHOT')) { + maven { + name = 'ASF Snapshot repo' + url = 'https://repository.apache.org/content/repositories/snapshots' + } + } + } +} subprojects { subproject -> @@ -44,7 +51,6 @@ subprojects { subproject -> userOrg = "grails" isGrailsPlugin = name.startsWith('grails-plugin') isBuildSnapshot = version.toString().endsWith("-SNAPSHOT") - groovyVersion = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion } if (isGrailsPlugin) { @@ -53,12 +59,6 @@ subprojects { subproject -> group "org.grails" } - repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } - maven { url "https://repository.apache.org/content/repositories/snapshots" } - } - if (subproject.name.startsWith("examples")) { apply plugin: "org.grails.grails-web" } else if (isGrailsPlugin) { diff --git a/settings.gradle b/settings.gradle index 810ed5a5fb..c7a083cea2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,26 +1,32 @@ plugins { - id "com.gradle.enterprise" version "3.18.1" + id 'com.gradle.develocity' version '3.18.1' id 'com.gradle.common-custom-user-data-gradle-plugin' version '2.0.2' } -gradleEnterprise { +def isCI = System.getenv('CI') != null +def isLocal = !isCI +def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null +def isBuildCacheAuthenticated = + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null && + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null + +develocity { server = 'https://ge.grails.org' buildScan { - publishAlwaysIf(System.getenv('CI') == 'true') - publishIfAuthenticated() - uploadInBackground = System.getenv("CI") == null - capture { - taskInputFiles = true - } + publishing.onlyIf { isAuthenticated } + uploadInBackground = isLocal } } buildCache { - local { enabled = System.getenv('CI') != 'true' } - remote(gradleEnterprise.buildCache) { - def isAuthenticated = System.getenv('GRADLE_ENTERPRISE_ACCESS_KEY') - push = System.getenv('CI') == 'true' && isAuthenticated + local { enabled = isLocal } + remote(develocity.buildCache) { + push = isCI && isBuildCacheAuthenticated enabled = true + usernameAndPassword( + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: '', + System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: '' + ) } }