Compare commits

...

29 Commits

Author SHA1 Message Date
Daz DeBoer
ef76a971e2 Simplify GE-inject config params (#863) 2023-08-28 11:59:09 -06:00
dependabot[bot]
98d77952ea Bump the npm-dependencies group with 1 update
Bumps the npm-dependencies group with 1 update: [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest).

- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

---
updated-dependencies:
- dependency-name: "@types/jest"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-28 18:47:31 +02:00
Daz DeBoer
3122f2c659 Mention GE authentication with GE injection 2023-08-23 12:07:20 -06:00
Daz DeBoer
53c4cf6c4c Merge pull request #861 from gradle/dd/dependency-updates
Dependency updates
2023-08-23 15:59:29 +02:00
daz
f2d7085b02 Add octokit to dependabot ignores 2023-08-22 10:28:15 -06:00
dependabot[bot]
9124f04a83 Bump the npm-dependencies group with 3 updates
Updates `@typescript-eslint/parser` from 6.4.0 to 6.4.1
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.4.1/packages/parser)

Updates `jest` from 29.6.2 to 29.6.3
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v29.6.3/packages/jest)

Updates `prettier` from 3.0.1 to 3.0.2
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.0.1...3.0.2)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-dependencies
- dependency-name: jest
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-dependencies
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-dependencies
2023-08-22 09:13:40 -06:00
dependabot[bot]
c304f927c4 Bump the github-actions group with 1 update
Bumps the github-actions group with 1 update: [gradle/gradle-build-action](https://github.com/gradle/gradle-build-action).

- [Release notes](https://github.com/gradle/gradle-build-action/releases)
- [Commits](https://github.com/gradle/gradle-build-action/compare/v2.7.0...v2.7.1)

---
updated-dependencies:
- dependency-name: gradle/gradle-build-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 22:36:46 +00:00
Daz DeBoer
e3426b1f20 Merge pull request #857 from gradle/dd/inject-ge
Add support for Gradle Enterprise injection into Gradle Builds
2023-08-21 01:38:14 +02:00
daz
d79398df06 Add docs for GE injection 2023-08-20 16:30:34 -06:00
daz
b9cd1d9e69 Build outputs 2023-08-20 16:29:23 -06:00
daz
d4db33d499 Add integ-test for GE injection 2023-08-20 16:29:23 -06:00
daz
05acc776e8 Wire new init-script into action
- Copy init-script to Gradle User Home
- Rename init-scripts for consistency and clarity
2023-08-20 16:29:23 -06:00
daz
33c9bfac14 Fix test for dependency graph with configuration cache 2023-08-20 16:29:23 -06:00
daz
97d9c134b7 Add init-script for Gradle Enterprise injection
Adds a new init-script which can enable and configure the Gradle Enterprise plugin(s)
for a build, without needing to modify the settings script for the project.
The functionality is enabled and configured via environment variables or system properties.

Not yet wired into `gradle-build-action`.
2023-08-20 16:29:23 -06:00
Daz DeBoer
a617adb316 Minor documentation updates 2023-08-20 15:56:45 -06:00
Daz DeBoer
b156d58cac Document the cache-overwrite-existing parameter 2023-08-20 14:14:54 -06:00
Daz DeBoer
b946c060aa Document the gradle-version output parameter 2023-08-20 14:05:33 -06:00
Daz DeBoer
96bed685e4 Merge pull request #855 from gradle/dd/installed-toolchains
Detect installed java toolchains
2023-08-20 05:27:22 +02:00
daz
800e5e1e62 Fix check 2023-08-19 20:42:08 -06:00
daz
ff3f4cfbf8 Build outputs 2023-08-19 20:14:11 -06:00
daz
a07019c726 Inform Gradle where to locate pre-installed JDKs 2023-08-19 20:14:11 -06:00
daz
b17d107b8c Add test for detection of java toolchains 2023-08-19 20:14:11 -06:00
daz
12dcfaa735 Bump to the latest Foojay resolver 2023-08-19 17:24:51 -06:00
Daz DeBoer
9fb6114fb4 Merge pull request #854 from gradle/dd/existing-gradle-home
- Report the cache as disabled when Gradle User Home exists #434 
- Allow cache restore over pre-existing Gradle User Home #480
2023-08-19 22:27:30 +02:00
daz
50d07aa0e5 Build outputs 2023-08-19 13:37:53 -06:00
daz
3d49588efc Allow cache to overwrite existing Gradle User Home
Fixes #480
2023-08-19 13:37:53 -06:00
daz
68e1dcdea4 Report the cache as disabled when Gradle User Home exists
Fixes #434
2023-08-19 13:37:49 -06:00
daz
8cade330d4 Include provisioned Gradle version as action output
Fixes #259
2023-08-19 20:37:12 +02:00
daz
124cb765ee Update to Gradle 8.3 2023-08-19 10:32:05 -06:00
51 changed files with 1944 additions and 795 deletions

View File

@@ -20,7 +20,8 @@ updates:
schedule: schedule:
interval: "weekly" interval: "weekly"
ignore: ignore:
- dependency-name: "@types/node" - dependency-name: "@types/node" # Breaking change: update with next major release
- dependency-name: "@octokit/rest" # Tied to node version
groups: groups:
npm-dependencies: npm-dependencies:
patterns: patterns:

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=03ec176d388f2aa99defcadc3ac6adf8dd2bce5145a129659537c0874dea5ad1 distributionSha256Sum=591855b517fc635b9e04de1d05d5e76ada3f89f5fc76f87978d1b245b4f69225
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@@ -83,7 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=03ec176d388f2aa99defcadc3ac6adf8dd2bce5145a129659537c0874dea5ad1 distributionSha256Sum=591855b517fc635b9e04de1d05d5e76ada3f89f5fc76f87978d1b245b4f69225
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@@ -83,7 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=03ec176d388f2aa99defcadc3ac6adf8dd2bce5145a129659537c0874dea5ad1 distributionSha256Sum=591855b517fc635b9e04de1d05d5e76ada3f89f5fc76f87978d1b245b4f69225
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@@ -83,7 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum

View File

@@ -1,5 +1,5 @@
plugins { plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0") id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
} }
rootProject.name = 'basic' rootProject.name = 'basic'

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=03ec176d388f2aa99defcadc3ac6adf8dd2bce5145a129659537c0874dea5ad1 distributionSha256Sum=591855b517fc635b9e04de1d05d5e76ada3f89f5fc76f87978d1b245b4f69225
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@@ -83,7 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum

View File

@@ -0,0 +1 @@
// Required to keep dependabot happy

View File

@@ -0,0 +1 @@
rootProject.name = 'no-ge'

View File

@@ -44,6 +44,13 @@ jobs:
with: with:
cache-key-prefix: ${{github.run_number}}- cache-key-prefix: ${{github.run_number}}-
gradle-enterprise-injection:
uses: ./.github/workflows/integ-test-inject-gradle-enterprise.yml
with:
cache-key-prefix: ${{github.run_number}}-
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_SOLUTIONS_ACCESS_TOKEN }}
provision-gradle-versions: provision-gradle-versions:
uses: ./.github/workflows/integ-test-provision-gradle-versions.yml uses: ./.github/workflows/integ-test-provision-gradle-versions.yml
with: with:
@@ -83,3 +90,8 @@ jobs:
uses: ./.github/workflows/integ-test-sample-gradle-plugin.yml uses: ./.github/workflows/integ-test-sample-gradle-plugin.yml
with: with:
cache-key-prefix: ${{github.run_number}}- cache-key-prefix: ${{github.run_number}}-
toolchain-detection:
uses: ./.github/workflows/integ-test-detect-java-toolchains.yml
with:
cache-key-prefix: ${{github.run_number}}-

View File

@@ -20,7 +20,7 @@ jobs:
distribution: temurin distribution: temurin
java-version: 8 java-version: 8
- name: Setup Gradle - name: Setup Gradle
uses: gradle/gradle-build-action@v2.7.0 # Use a released version to avoid breakages uses: gradle/gradle-build-action@v2.7.1 # Use a released version to avoid breakages
- name: Run integration tests - name: Run integration tests
working-directory: test/init-scripts working-directory: test/init-scripts
run: ./gradlew check run: ./gradlew check

View File

@@ -22,7 +22,7 @@ jobs:
- name: Configure Gradle as default for unit test - name: Configure Gradle as default for unit test
uses: ./ uses: ./
with: with:
gradle-version: 8.2.1 gradle-version: 8.3
- name: Run tests - name: Run tests
run: | run: |
npm install npm install
@@ -71,6 +71,15 @@ jobs:
runner-os: '["ubuntu-latest"]' runner-os: '["ubuntu-latest"]'
download-dist: true download-dist: true
gradle-enterprise-injection:
needs: build-distribution
uses: ./.github/workflows/integ-test-inject-gradle-enterprise.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_SOLUTIONS_ACCESS_TOKEN }}
provision-gradle-versions: provision-gradle-versions:
needs: build-distribution needs: build-distribution
uses: ./.github/workflows/integ-test-provision-gradle-versions.yml uses: ./.github/workflows/integ-test-provision-gradle-versions.yml
@@ -124,3 +133,10 @@ jobs:
with: with:
runner-os: '["ubuntu-latest"]' runner-os: '["ubuntu-latest"]'
download-dist: true download-dist: true
toolchain-detection:
needs: build-distribution
uses: ./.github/workflows/integ-test-detect-java-toolchains.yml
with:
runner-os: '["ubuntu-latest"]'
download-dist: true

View File

@@ -41,3 +41,25 @@ jobs:
working-directory: .github/workflow-samples/groovy-dsl working-directory: .github/workflow-samples/groovy-dsl
continue-on-error: true continue-on-error: true
run: ./gradlew not-a-real-task run: ./gradlew not-a-real-task
pre-existing-gradle-home:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Build distribution
shell: bash
run: |
npm install
npm run build
- name: Pre-create Gradle User Home
shell: bash
run: |
mkdir ~/.gradle
mkdir ~/.gradle/caches
touch ~/.gradle/caches/dummy.txt
- name: Setup Gradle
uses: ./
- name: Run build
working-directory: .github/workflow-samples/groovy-dsl
run: ./gradlew assemble

View File

@@ -0,0 +1,113 @@
name: Test detect java toolchains
on:
workflow_call:
inputs:
cache-key-prefix:
type: string
runner-os:
type: string
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
download-dist:
type: boolean
default: false
env:
DOWNLOAD_DIST: ${{ inputs.download-dist }}
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: restore-java-toolchain-${{ inputs.cache-key-prefix }}
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
jobs:
# Test that pre-installed runner JDKs are detected
pre-installed-toolchains:
strategy:
matrix:
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Setup Gradle
uses: ./
- name: List detected toolchains
shell: bash
working-directory: .github/workflow-samples/groovy-dsl
run: |
gradle -q javaToolchains > output.txt
cat output.txt
- name: Verify detected toolchains
shell: bash
working-directory: .github/workflow-samples/groovy-dsl
run: |
grep -q 'Eclipse Temurin JDK 1.8' output.txt || (echo "::error::Did not detect preinstalled JDK 1.8" && exit 1)
grep -q 'Eclipse Temurin JDK 11' output.txt || (echo "::error::Did not detect preinstalled JDK 11" && exit 1)
grep -q 'Eclipse Temurin JDK 17' output.txt || (echo "::error::Did not detect preinstalled JDK 17" && exit 1)
# Test that JDKs provisioned by setup-java are detected
setup-java-installed-toolchain:
strategy:
matrix:
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Setup Java 20
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '20'
- name: Setup Java 16
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '16'
- name: Setup Gradle
uses: ./
- name: List detected toolchains
shell: bash
working-directory: .github/workflow-samples/groovy-dsl
run: |
gradle -q javaToolchains > output.txt
cat output.txt
- name: Verify detected toolchains
shell: bash
working-directory: .github/workflow-samples/groovy-dsl
run: |
grep -q 'Eclipse Temurin JDK 16' output.txt || (echo "::error::Did not detect setup-java installed JDK 16" && exit 1)
grep -q 'Eclipse Temurin JDK 20' output.txt || (echo "::error::Did not detect setup-java installed JDK 20" && exit 1)
# Test that predefined JDK detection property is not overwritten by action
check-no-overwrite:
strategy:
matrix:
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Configure java installations env var in Gradle User Home
shell: bash
run: |
mkdir -p ~/.gradle
echo "org.gradle.java.installations.fromEnv=XXXXX" > ~/.gradle/gradle.properties
- name: Setup Gradle
uses: ./
- name: Check gradle.properties
shell: bash
run: |
cat ~/.gradle/gradle.properties
if grep -q 'org.gradle.java.installations.fromEnv=JAVA_HOME' ~/.gradle/gradle.properties ; then
echo 'Found overwritten fromEnv'
exit 1
fi
if ! grep -q 'org.gradle.java.installations.fromEnv=XXXXX' ~/.gradle/gradle.properties ; then
echo 'Did NOT find original fromEnv'
exit 1
fi

View File

@@ -0,0 +1,60 @@
name: Test gradle enterprise injection
on:
workflow_call:
inputs:
cache-key-prefix:
type: string
runner-os:
type: string
default: '["ubuntu-latest", "windows-latest", "macos-latest"]'
download-dist:
type: boolean
default: false
secrets:
GRADLE_ENTERPRISE_ACCESS_KEY:
required: true
env:
DOWNLOAD_DIST: ${{ inputs.download-dist }}
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: provision-gradle-versions-${{ inputs.cache-key-prefix }}
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
GRADLE_ENTERPRISE_INJECTION_ENABLED: true
GRADLE_ENTERPRISE_URL: https://ge.solutions-team.gradle.com
GRADLE_ENTERPRISE_PLUGIN_VERSION: 3.14.1
GRADLE_ENTERPRISE_CCUD_PLUGIN_VERSION: 1.11.1
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
jobs:
inject-gradle-enterprise:
strategy:
matrix:
gradle: [current, 7.6.2, 6.9.4, 5.6.4]
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
- name: Setup Gradle
id: setup-gradle
uses: ./
with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
gradle-version: ${{ matrix.gradle }}
- name: Run Gradle build
id: gradle
working-directory: .github/workflow-samples/no-ge
run: gradle help
- name: Check Build Scan url
if: ${{ !steps.gradle.outputs.build-scan-url }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('No Build Scan detected')

View File

@@ -55,6 +55,17 @@ jobs:
- name: Test use release-candidate - name: Test use release-candidate
working-directory: .github/workflow-samples/no-wrapper working-directory: .github/workflow-samples/no-wrapper
run: gradle help run: gradle help
- name: Setup Gradle with current
id: gradle-current
uses: ./
with:
gradle-version: current
- name: Check current version output parameter
if: ${{ !startsWith(steps.gradle-current.outputs.gradle-version , '8.') }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Gradle version parameter not set correctly: value was "${{ steps.gradle-current.outputs.gradle-version }}"')
gradle-versions: gradle-versions:
strategy: strategy:
@@ -80,10 +91,17 @@ jobs:
distribution: temurin distribution: temurin
java-version: 8 java-version: 8
- name: Setup Gradle - name: Setup Gradle
id: setup-gradle
uses: ./ uses: ./
with: with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches cache-read-only: false # For testing, allow writing cache entries on non-default branches
gradle-version: ${{ matrix.gradle }} gradle-version: ${{ matrix.gradle }}
- name: Check output parameter
if: ${{ steps.setup-gradle.outputs.gradle-version != matrix.gradle }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Gradle version parameter not set correctly: value was "${{ steps.setup-gradle.outputs.gradle-version }}"')
- name: Run Gradle build - name: Run Gradle build
id: gradle id: gradle
working-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }} working-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}

View File

@@ -99,3 +99,40 @@ jobs:
working-directory: .github/workflow-samples/groovy-dsl working-directory: .github/workflow-samples/groovy-dsl
run: ./gradlew test run: ./gradlew test
# Test that a pre-existing gradle-user-home can be overwritten by the restored cache
pre-existing-gradle-home:
needs: seed-build
strategy:
matrix:
os: ${{fromJSON(inputs.runner-os)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download distribution if required
uses: ./.github/actions/download-dist
- name: Pre-create Gradle User Home
shell: bash
run: |
mkdir -p ~/.gradle/caches
touch ~/.gradle/gradle.properties
touch ~/.gradle/caches/dummy.txt
- name: Setup Gradle
uses: ./
with:
cache-read-only: true
cache-overwrite-existing: true
- name: Check that pre-existing content still exists
shell: bash
run: |
if [ ! -e ~/.gradle/caches/dummy.txt ]; then
echo "::error ::Should find dummy.txt after cache restore"
exit 1
fi
if [ ! -e ~/.gradle/gradle.properties ]; then
echo "::error ::Should find gradle.properties after cache restore"
exit 1
fi
- name: Execute Gradle build with --offline
working-directory: .github/workflow-samples/groovy-dsl
run: ./gradlew test --offline

View File

@@ -1,3 +1,3 @@
# Configuration file for asdf version manager # Configuration file for asdf version manager
nodejs 16.18.1 nodejs 16.18.1
gradle 8.2.1 gradle 8.3

View File

@@ -11,6 +11,7 @@ However, the `gradle-build-action` offers a number of advantages over this appro
- Easily [configure your workflow to use a specific version of Gradle](#use-a-specific-gradle-version) using the `gradle-version` parameter. Gradle distributions are automatically downloaded and cached. - Easily [configure your workflow to use a specific version of Gradle](#use-a-specific-gradle-version) using the `gradle-version` parameter. Gradle distributions are automatically downloaded and cached.
- More sophisticated and more efficient caching of Gradle User Home between invocations, compared to `setup-java` and most custom configurations using `actions/cache`. [More details below](#caching). - More sophisticated and more efficient caching of Gradle User Home between invocations, compared to `setup-java` and most custom configurations using `actions/cache`. [More details below](#caching).
- Detailed reporting of cache usage and cache configuration options allow you to [optimize the use of the GitHub actions cache](#optimizing-cache-effectiveness). - Detailed reporting of cache usage and cache configuration options allow you to [optimize the use of the GitHub actions cache](#optimizing-cache-effectiveness).
- [Generate and Submit a GitHub Dependency Graph](#github-dependency-graph-support) for your project, enabling Dependabot security alerts.
- [Automatic capture of Build Scan® links](#build-scans) from the build, making these easier to locate for workflow run. - [Automatic capture of Build Scan® links](#build-scans) from the build, making these easier to locate for workflow run.
The `gradle-build-action` is designed to provide these benefits with minimal configuration. The `gradle-build-action` is designed to provide these benefits with minimal configuration.
@@ -71,6 +72,8 @@ Moreover, you can use the following aliases:
This can be handy to automatically verify your build works with the latest release candidate of Gradle: This can be handy to automatically verify your build works with the latest release candidate of Gradle:
The actual Gradle version used is available as an action output: `gradle-version`.
```yaml ```yaml
name: Test latest Gradle RC name: Test latest Gradle RC
on: on:
@@ -86,11 +89,14 @@ jobs:
distribution: temurin distribution: temurin
java-version: 11 java-version: 11
- uses: gradle/gradle-build-action@v2 - uses: gradle/gradle-build-action@v2
id: setup-gradle
with: with:
gradle-version: release-candidate gradle-version: release-candidate
- run: gradle build --dry-run # just test build configuration - run: gradle build --dry-run # just test build configuration
- run: echo "The release-candidate version was ${{ steps.setup-gradle.outputs.gradle-version }}"
``` ```
## Caching build state between Jobs ## Caching build state between Jobs
The `gradle-build-action` will use the GitHub Actions cache to save and restore reusable state that may be speed up a subsequent build invocation. This includes most content that is downloaded from the internet as part of a build, as well as expensive to create content like compiled build scripts, transformed Jar files, etc. The `gradle-build-action` will use the GitHub Actions cache to save and restore reusable state that may be speed up a subsequent build invocation. This includes most content that is downloaded from the internet as part of a build, as well as expensive to create content like compiled build scripts, transformed Jar files, etc.
@@ -140,6 +146,20 @@ In certain circumstances it may be desirable to start with a clean Gradle User H
cache-write-only: true cache-write-only: true
``` ```
### Overwriting an existing Gradle User Home
When the action detects that the Gradle User Home caches directory already exists (`~/.gradle/caches`), then by default it will not overwrite the existing content of this directory.
This can occur when a prior action initializes this directory, or when using a self-hosted runner that retains this directory between uses.
In this case the Job Summary will display a message like:
> Caching for gradle-build-action was disabled due to pre-existing Gradle User Home
If you want override the default and have the `gradle-build-action` caches overwrite existing content in the Gradle User Home, you can set the `cache-overwrite-existing` parameter to 'true':
```yaml
cache-overwrite-existing: true
```
### Incompatibility with other caching mechanisms ### Incompatibility with other caching mechanisms
When using `gradle-build-action` we recommend that you avoid using other mechanisms to save and restore the Gradle User Home. When using `gradle-build-action` we recommend that you avoid using other mechanisms to save and restore the Gradle User Home.
@@ -695,7 +715,7 @@ jobs:
## Gradle version compatibility ## Gradle version compatibility
The plugin should be compatible with all versions of Gradle >= 5.0, and has been tested against The GitHub Dependency Graph plugin should be compatible with all versions of Gradle >= 5.0, and has been tested against
Gradle versions "5.6.4", "6.9.4", "7.0.2", "7.6.2", "8.0.2" and the current Gradle release. Gradle versions "5.6.4", "6.9.4", "7.0.2", "7.6.2", "8.0.2" and the current Gradle release.
The plugin is compatible with running Gradle with the configuration-cache enabled. However, this support is The plugin is compatible with running Gradle with the configuration-cache enabled. However, this support is
@@ -706,3 +726,54 @@ limited to Gradle "8.1.0" and later:
To use this plugin with versions of Gradle older than "8.1.0", you'll need to invoke Gradle with the To use this plugin with versions of Gradle older than "8.1.0", you'll need to invoke Gradle with the
configuration-cache disabled. configuration-cache disabled.
# Gradle Enterprise plugin injection
The `gradle-build-action` provides support for injecting and configuring the Gradle Enterprise Gradle plugin into any Gradle build, without any modification to the project sources.
This is achieved via an init-script installed into Gradle User Home, which is enabled and parameterized via environment variables.
The same auto-injection behavior is available for the Common Custom User Data Gradle plugin, which enriches any build scans published with additional useful information.
## Enabling Gradle Enterprise injection
In order to enable Gradle Enterprise for your build, you must provide the required configuration via environment variables.
Here's a minimal example:
```yaml
name: Run build with Gradle Enterprise injection
env:
GRADLE_ENTERPRISE_INJECTION_ENABLED: true
GRADLE_ENTERPRISE_URL: https://ge.gradle.org
GRADLE_ENTERPRISE_PLUGIN_VERSION: 3.14.1
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_ACCESS_KEY }} # Required to publish scans to ge.gradle.org
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Run a Gradle build with Gradle Enterprise injection enabled
run: ./gradlew build
```
This configuration will automatically apply `v3.14.1` of the [Gradle Enterprise Gradle plugin](https://docs.gradle.com/enterprise/gradle-plugin/), and publish build scans to https://ge.gradle.org.
Note that the `ge.gradle.org` server requires authentication in order to publish scans. The provided `GRADLE_ENTERPRISE_ACCESS_KEY` isn't required by the Gradle Enterprise injection script,
but will be used by the GE plugin in order to authenticate with the server.
## Configuring Gradle Enterprise injection
The `init-script` supports a number of additional configuration parameters that you may fine useful. All configuration options (required and optional) are detailed below:
| Variable | Required | Description |
| --- | --- | --- |
| GRADLE_ENTERPRISE_INJECTION_ENABLED | :white_check_mark: | enables Gradle Enterprise injection |
| GRADLE_ENTERPRISE_URL | :white_check_mark: | the URL of the Gradle Enterprise server |
| GRADLE_ENTERPRISE_ALLOW_UNTRUSTED_SERVER | | allow communication with an untrusted server; set to _true_ if your Gradle Enterprise instance is using a self-signed certificate |
| GRADLE_ENTERPRISE_ENFORCE_URL | | enforce the configured Gradle Enterprise URL over a URL configured in the project's build; set to _true_ to enforce publication of build scans to the configured Gradle Enterprise URL |
| GRADLE_ENTERPRISE_PLUGIN_VERSION | :white_check_mark: | the version of the [Gradle Enterprise Gradle plugin](https://docs.gradle.com/enterprise/gradle-plugin/) to apply |
| GRADLE_ENTERPRISE_CCUD_PLUGIN_VERSION | | the version of the [Common Custom User Data Gradle plugin](https://github.com/gradle/common-custom-user-data-gradle-plugin) to apply, if any |
| GRADLE_ENTERPRISE_PLUGIN_REPOSITORY_URL | | the URL of the repository to use when resolving the GE and CCUD plugins; the Gradle Plugin Portal is used by default |

View File

@@ -35,6 +35,11 @@ inputs:
required: false required: false
default: false default: false
cache-overwrite-existing:
description: When 'true', a pre-existing Gradle User Home will not prevent the cache from being restored.
required: false
default: false
gradle-home-cache-includes: gradle-home-cache-includes:
description: Paths within Gradle User Home to cache. description: Paths within Gradle User Home to cache.
required: false required: false
@@ -90,6 +95,8 @@ outputs:
description: Link to the Build Scan® generated by a Gradle build. Note that this output applies to a Step executing Gradle, not to the `gradle-build-action` Step itself. description: Link to the Build Scan® generated by a Gradle build. Note that this output applies to a Step executing Gradle, not to the `gradle-build-action` Step itself.
dependency-graph-file: dependency-graph-file:
description: Path to the GitHub Dependency Graph snapshot file generated by a Gradle build. Note that this output applies to a Step executing Gradle, not to the `gradle-build-action` Step itself. description: Path to the GitHub Dependency Graph snapshot file generated by a Gradle build. Note that this output applies to a Step executing Gradle, not to the `gradle-build-action` Step itself.
gradle-version:
description: Version of Gradle that was setup by the action
runs: runs:
using: 'node16' using: 'node16'

59
dist/main/index.js vendored
View File

@@ -72971,11 +72971,22 @@ class GradleStateCache {
return path_1.default.resolve(this.gradleUserHome, rawPath); return path_1.default.resolve(this.gradleUserHome, rawPath);
} }
initializeGradleUserHome(gradleUserHome, initScriptsDir) { initializeGradleUserHome(gradleUserHome, initScriptsDir) {
const gradleProperties = path_1.default.resolve(gradleUserHome, 'gradle.properties');
const existingGradleProperties = fs_1.default.existsSync(gradleProperties)
? fs_1.default.readFileSync(gradleProperties, 'utf8')
: '';
if (!existingGradleProperties.includes('org.gradle.java.installations.fromEnv=')) {
fs_1.default.appendFileSync(gradleProperties, `
# Auto-detect pre-installed JDKs
org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64
`);
}
const initScriptFilenames = [ const initScriptFilenames = [
'build-result-capture.init.gradle', 'gradle-build-action.build-result-capture.init.gradle',
'build-result-capture-service.plugin.groovy', 'gradle-build-action.build-result-capture-service.plugin.groovy',
'github-dependency-graph.init.gradle', 'gradle-build-action.github-dependency-graph.init.gradle',
'github-dependency-graph-gradle-plugin-apply.groovy' 'gradle-build-action.github-dependency-graph-gradle-plugin-apply.groovy',
'gradle-build-action.inject-gradle-enterprise.init.gradle'
]; ];
for (const initScriptFilename of initScriptFilenames) { for (const initScriptFilename of initScriptFilenames) {
const initScriptContent = this.readInitScriptAsString(initScriptFilename); const initScriptContent = this.readInitScriptAsString(initScriptFilename);
@@ -73467,6 +73478,7 @@ class CacheListener {
this.cacheReadOnly = false; this.cacheReadOnly = false;
this.cacheWriteOnly = false; this.cacheWriteOnly = false;
this.cacheDisabled = false; this.cacheDisabled = false;
this.cacheDisabledReason = 'disabled';
} }
get fullyRestored() { get fullyRestored() {
return this.cacheEntries.every(x => !x.wasRequestedButNotRestored()); return this.cacheEntries.every(x => !x.wasRequestedButNotRestored());
@@ -73475,7 +73487,7 @@ class CacheListener {
if (!cache.isFeatureAvailable()) if (!cache.isFeatureAvailable())
return 'not available'; return 'not available';
if (this.cacheDisabled) if (this.cacheDisabled)
return 'disabled'; return this.cacheDisabledReason;
if (this.cacheWriteOnly) if (this.cacheWriteOnly)
return 'write-only'; return 'write-only';
if (this.cacheReadOnly) if (this.cacheReadOnly)
@@ -73681,7 +73693,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getUniqueLabelForJobInstanceValues = exports.getUniqueLabelForJobInstance = exports.getCacheKeyForJob = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0; exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getUniqueLabelForJobInstanceValues = exports.getUniqueLabelForJobInstance = exports.getCacheKeyForJob = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
const github = __importStar(__nccwpck_require__(5438)); const github = __importStar(__nccwpck_require__(5438));
@@ -73713,6 +73725,10 @@ function isCacheWriteOnly() {
return params.isCacheWriteOnly(); return params.isCacheWriteOnly();
} }
exports.isCacheWriteOnly = isCacheWriteOnly; exports.isCacheWriteOnly = isCacheWriteOnly;
function isCacheOverwriteExisting() {
return params.isCacheOverwriteExisting();
}
exports.isCacheOverwriteExisting = isCacheOverwriteExisting;
function isCacheDebuggingEnabled() { function isCacheDebuggingEnabled() {
return params.isCacheDebuggingEnabled(); return params.isCacheDebuggingEnabled();
} }
@@ -73963,10 +73979,15 @@ function restore(gradleUserHome, cacheListener) {
return; return;
} }
if (gradleStateCache.cacheOutputExists()) { if (gradleStateCache.cacheOutputExists()) {
if (!(0, cache_utils_1.isCacheOverwriteExisting)()) {
core.info('Gradle User Home already exists: will not restore from cache.'); core.info('Gradle User Home already exists: will not restore from cache.');
gradleStateCache.init(); gradleStateCache.init();
cacheListener.cacheDisabled = true;
cacheListener.cacheDisabledReason = 'disabled due to pre-existing Gradle User Home';
return; return;
} }
core.info('Gradle User Home already exists: will overwrite with cached contents.');
}
gradleStateCache.init(); gradleStateCache.init();
core.saveState(CACHE_RESTORED_VAR, true); core.saveState(CACHE_RESTORED_VAR, true);
if ((0, cache_utils_1.isCacheWriteOnly)()) { if ((0, cache_utils_1.isCacheWriteOnly)()) {
@@ -74455,7 +74476,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DependencyGraphOption = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0; exports.DependencyGraphOption = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const string_argv_1 = __nccwpck_require__(9663); const string_argv_1 = __nccwpck_require__(9663);
function isCacheDisabled() { function isCacheDisabled() {
@@ -74470,6 +74491,10 @@ function isCacheWriteOnly() {
return getBooleanInput('cache-write-only'); return getBooleanInput('cache-write-only');
} }
exports.isCacheWriteOnly = isCacheWriteOnly; exports.isCacheWriteOnly = isCacheWriteOnly;
function isCacheOverwriteExisting() {
return getBooleanInput('cache-overwrite-existing');
}
exports.isCacheOverwriteExisting = isCacheOverwriteExisting;
function isCacheStrictMatch() { function isCacheStrictMatch() {
return getBooleanInput('gradle-home-cache-strict-match'); return getBooleanInput('gradle-home-cache-strict-match');
} }
@@ -74827,6 +74852,13 @@ function addToPath(executable) {
}); });
} }
function installGradle(version) { function installGradle(version) {
return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield resolveGradleVersion(version);
core.setOutput('gradle-version', versionInfo.version);
return installGradleVersion(versionInfo);
});
}
function resolveGradleVersion(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (version) { switch (version) {
case 'current': case 'current':
@@ -74847,15 +74879,14 @@ function installGradle(version) {
} }
function gradleCurrent() { function gradleCurrent() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`); return yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`);
return installGradleVersion(versionInfo);
}); });
} }
function gradleReleaseCandidate() { function gradleReleaseCandidate() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`); const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`);
if (versionInfo && versionInfo.version && versionInfo.downloadUrl) { if (versionInfo && versionInfo.version && versionInfo.downloadUrl) {
return installGradleVersion(versionInfo); return versionInfo;
} }
core.info('No current release-candidate found, will fallback to current'); core.info('No current release-candidate found, will fallback to current');
return gradleCurrent(); return gradleCurrent();
@@ -74863,14 +74894,12 @@ function gradleReleaseCandidate() {
} }
function gradleNightly() { function gradleNightly() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`); return yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`);
return installGradleVersion(versionInfo);
}); });
} }
function gradleReleaseNightly() { function gradleReleaseNightly() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`); return yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`);
return installGradleVersion(versionInfo);
}); });
} }
function gradle(version) { function gradle(version) {
@@ -74879,7 +74908,7 @@ function gradle(version) {
if (!versionInfo) { if (!versionInfo) {
throw new Error(`Gradle version ${version} does not exists`); throw new Error(`Gradle version ${version} does not exists`);
} }
return installGradleVersion(versionInfo); return versionInfo;
}); });
} }
function gradleVersionDeclaration(url) { function gradleVersionDeclaration(url) {

File diff suppressed because one or more lines are too long

39
dist/post/index.js vendored
View File

@@ -72971,11 +72971,22 @@ class GradleStateCache {
return path_1.default.resolve(this.gradleUserHome, rawPath); return path_1.default.resolve(this.gradleUserHome, rawPath);
} }
initializeGradleUserHome(gradleUserHome, initScriptsDir) { initializeGradleUserHome(gradleUserHome, initScriptsDir) {
const gradleProperties = path_1.default.resolve(gradleUserHome, 'gradle.properties');
const existingGradleProperties = fs_1.default.existsSync(gradleProperties)
? fs_1.default.readFileSync(gradleProperties, 'utf8')
: '';
if (!existingGradleProperties.includes('org.gradle.java.installations.fromEnv=')) {
fs_1.default.appendFileSync(gradleProperties, `
# Auto-detect pre-installed JDKs
org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64
`);
}
const initScriptFilenames = [ const initScriptFilenames = [
'build-result-capture.init.gradle', 'gradle-build-action.build-result-capture.init.gradle',
'build-result-capture-service.plugin.groovy', 'gradle-build-action.build-result-capture-service.plugin.groovy',
'github-dependency-graph.init.gradle', 'gradle-build-action.github-dependency-graph.init.gradle',
'github-dependency-graph-gradle-plugin-apply.groovy' 'gradle-build-action.github-dependency-graph-gradle-plugin-apply.groovy',
'gradle-build-action.inject-gradle-enterprise.init.gradle'
]; ];
for (const initScriptFilename of initScriptFilenames) { for (const initScriptFilename of initScriptFilenames) {
const initScriptContent = this.readInitScriptAsString(initScriptFilename); const initScriptContent = this.readInitScriptAsString(initScriptFilename);
@@ -73467,6 +73478,7 @@ class CacheListener {
this.cacheReadOnly = false; this.cacheReadOnly = false;
this.cacheWriteOnly = false; this.cacheWriteOnly = false;
this.cacheDisabled = false; this.cacheDisabled = false;
this.cacheDisabledReason = 'disabled';
} }
get fullyRestored() { get fullyRestored() {
return this.cacheEntries.every(x => !x.wasRequestedButNotRestored()); return this.cacheEntries.every(x => !x.wasRequestedButNotRestored());
@@ -73475,7 +73487,7 @@ class CacheListener {
if (!cache.isFeatureAvailable()) if (!cache.isFeatureAvailable())
return 'not available'; return 'not available';
if (this.cacheDisabled) if (this.cacheDisabled)
return 'disabled'; return this.cacheDisabledReason;
if (this.cacheWriteOnly) if (this.cacheWriteOnly)
return 'write-only'; return 'write-only';
if (this.cacheReadOnly) if (this.cacheReadOnly)
@@ -73681,7 +73693,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getUniqueLabelForJobInstanceValues = exports.getUniqueLabelForJobInstance = exports.getCacheKeyForJob = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0; exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getUniqueLabelForJobInstanceValues = exports.getUniqueLabelForJobInstance = exports.getCacheKeyForJob = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
const github = __importStar(__nccwpck_require__(5438)); const github = __importStar(__nccwpck_require__(5438));
@@ -73713,6 +73725,10 @@ function isCacheWriteOnly() {
return params.isCacheWriteOnly(); return params.isCacheWriteOnly();
} }
exports.isCacheWriteOnly = isCacheWriteOnly; exports.isCacheWriteOnly = isCacheWriteOnly;
function isCacheOverwriteExisting() {
return params.isCacheOverwriteExisting();
}
exports.isCacheOverwriteExisting = isCacheOverwriteExisting;
function isCacheDebuggingEnabled() { function isCacheDebuggingEnabled() {
return params.isCacheDebuggingEnabled(); return params.isCacheDebuggingEnabled();
} }
@@ -73963,10 +73979,15 @@ function restore(gradleUserHome, cacheListener) {
return; return;
} }
if (gradleStateCache.cacheOutputExists()) { if (gradleStateCache.cacheOutputExists()) {
if (!(0, cache_utils_1.isCacheOverwriteExisting)()) {
core.info('Gradle User Home already exists: will not restore from cache.'); core.info('Gradle User Home already exists: will not restore from cache.');
gradleStateCache.init(); gradleStateCache.init();
cacheListener.cacheDisabled = true;
cacheListener.cacheDisabledReason = 'disabled due to pre-existing Gradle User Home';
return; return;
} }
core.info('Gradle User Home already exists: will overwrite with cached contents.');
}
gradleStateCache.init(); gradleStateCache.init();
core.saveState(CACHE_RESTORED_VAR, true); core.saveState(CACHE_RESTORED_VAR, true);
if ((0, cache_utils_1.isCacheWriteOnly)()) { if ((0, cache_utils_1.isCacheWriteOnly)()) {
@@ -74323,7 +74344,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DependencyGraphOption = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0; exports.DependencyGraphOption = exports.getDependencyGraphOption = exports.isDependencyGraphEnabled = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleExecutable = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const string_argv_1 = __nccwpck_require__(9663); const string_argv_1 = __nccwpck_require__(9663);
function isCacheDisabled() { function isCacheDisabled() {
@@ -74338,6 +74359,10 @@ function isCacheWriteOnly() {
return getBooleanInput('cache-write-only'); return getBooleanInput('cache-write-only');
} }
exports.isCacheWriteOnly = isCacheWriteOnly; exports.isCacheWriteOnly = isCacheWriteOnly;
function isCacheOverwriteExisting() {
return getBooleanInput('cache-overwrite-existing');
}
exports.isCacheOverwriteExisting = isCacheOverwriteExisting;
function isCacheStrictMatch() { function isCacheStrictMatch() {
return getBooleanInput('gradle-home-cache-strict-match'); return getBooleanInput('gradle-home-cache-strict-match');
} }

File diff suppressed because one or more lines are too long

1484
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -43,18 +43,18 @@
}, },
"devDependencies": { "devDependencies": {
"@types/node": "16.18.38", "@types/node": "16.18.38",
"@types/jest": "29.5.3", "@types/jest": "29.5.4",
"@types/unzipper": "0.10.6", "@types/unzipper": "0.10.6",
"@typescript-eslint/parser": "6.4.0", "@typescript-eslint/parser": "6.4.1",
"@vercel/ncc": "0.36.1", "@vercel/ncc": "0.36.1",
"eslint": "8.47.0", "eslint": "8.47.0",
"eslint-plugin-github": "4.9.2", "eslint-plugin-github": "4.9.2",
"eslint-plugin-jest": "27.2.3", "eslint-plugin-jest": "27.2.3",
"eslint-plugin-prettier": "5.0.0", "eslint-plugin-prettier": "5.0.0",
"jest": "29.6.2", "jest": "29.6.3",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"patch-package": "8.0.0", "patch-package": "8.0.0",
"prettier": "3.0.1", "prettier": "3.0.2",
"ts-jest": "29.1.1", "ts-jest": "29.1.1",
"typescript": "5.1.6" "typescript": "5.1.6"
} }

View File

@@ -172,11 +172,28 @@ export class GradleStateCache {
} }
private initializeGradleUserHome(gradleUserHome: string, initScriptsDir: string): void { private initializeGradleUserHome(gradleUserHome: string, initScriptsDir: string): void {
// Ensure that pre-installed java versions are detected. Only add property if it isn't already defined.
const gradleProperties = path.resolve(gradleUserHome, 'gradle.properties')
const existingGradleProperties = fs.existsSync(gradleProperties)
? fs.readFileSync(gradleProperties, 'utf8')
: ''
if (!existingGradleProperties.includes('org.gradle.java.installations.fromEnv=')) {
fs.appendFileSync(
gradleProperties,
`
# Auto-detect pre-installed JDKs
org.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64
`
)
}
// Copy init scripts from src/resources
const initScriptFilenames = [ const initScriptFilenames = [
'build-result-capture.init.gradle', 'gradle-build-action.build-result-capture.init.gradle',
'build-result-capture-service.plugin.groovy', 'gradle-build-action.build-result-capture-service.plugin.groovy',
'github-dependency-graph.init.gradle', 'gradle-build-action.github-dependency-graph.init.gradle',
'github-dependency-graph-gradle-plugin-apply.groovy' 'gradle-build-action.github-dependency-graph-gradle-plugin-apply.groovy',
'gradle-build-action.inject-gradle-enterprise.init.gradle'
] ]
for (const initScriptFilename of initScriptFilenames) { for (const initScriptFilename of initScriptFilenames) {
const initScriptContent = this.readInitScriptAsString(initScriptFilename) const initScriptContent = this.readInitScriptAsString(initScriptFilename)

View File

@@ -10,6 +10,7 @@ export class CacheListener {
cacheReadOnly = false cacheReadOnly = false
cacheWriteOnly = false cacheWriteOnly = false
cacheDisabled = false cacheDisabled = false
cacheDisabledReason = 'disabled'
get fullyRestored(): boolean { get fullyRestored(): boolean {
return this.cacheEntries.every(x => !x.wasRequestedButNotRestored()) return this.cacheEntries.every(x => !x.wasRequestedButNotRestored())
@@ -17,7 +18,7 @@ export class CacheListener {
get cacheStatus(): string { get cacheStatus(): string {
if (!cache.isFeatureAvailable()) return 'not available' if (!cache.isFeatureAvailable()) return 'not available'
if (this.cacheDisabled) return 'disabled' if (this.cacheDisabled) return this.cacheDisabledReason
if (this.cacheWriteOnly) return 'write-only' if (this.cacheWriteOnly) return 'write-only'
if (this.cacheReadOnly) return 'read-only' if (this.cacheReadOnly) return 'read-only'
return 'enabled' return 'enabled'

View File

@@ -37,6 +37,10 @@ export function isCacheWriteOnly(): boolean {
return params.isCacheWriteOnly() return params.isCacheWriteOnly()
} }
export function isCacheOverwriteExisting(): boolean {
return params.isCacheOverwriteExisting()
}
export function isCacheDebuggingEnabled(): boolean { export function isCacheDebuggingEnabled(): boolean {
return params.isCacheDebuggingEnabled() return params.isCacheDebuggingEnabled()
} }

View File

@@ -1,5 +1,11 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import {isCacheCleanupEnabled, isCacheDisabled, isCacheReadOnly, isCacheWriteOnly} from './cache-utils' import {
isCacheCleanupEnabled,
isCacheDisabled,
isCacheReadOnly,
isCacheWriteOnly,
isCacheOverwriteExisting
} from './cache-utils'
import {CacheListener} from './cache-reporting' import {CacheListener} from './cache-reporting'
import {DaemonController} from './daemon-controller' import {DaemonController} from './daemon-controller'
import {GradleStateCache} from './cache-base' import {GradleStateCache} from './cache-base'
@@ -26,11 +32,16 @@ export async function restore(gradleUserHome: string, cacheListener: CacheListen
} }
if (gradleStateCache.cacheOutputExists()) { if (gradleStateCache.cacheOutputExists()) {
if (!isCacheOverwriteExisting()) {
core.info('Gradle User Home already exists: will not restore from cache.') core.info('Gradle User Home already exists: will not restore from cache.')
// Initialize pre-existing Gradle User Home. // Initialize pre-existing Gradle User Home.
gradleStateCache.init() gradleStateCache.init()
cacheListener.cacheDisabled = true
cacheListener.cacheDisabledReason = 'disabled due to pre-existing Gradle User Home'
return return
} }
core.info('Gradle User Home already exists: will overwrite with cached contents.')
}
gradleStateCache.init() gradleStateCache.init()
// Mark the state as restored so that post-action will perform save. // Mark the state as restored so that post-action will perform save.

View File

@@ -13,6 +13,10 @@ export function isCacheWriteOnly(): boolean {
return getBooleanInput('cache-write-only') return getBooleanInput('cache-write-only')
} }
export function isCacheOverwriteExisting(): boolean {
return getBooleanInput('cache-overwrite-existing')
}
export function isCacheStrictMatch(): boolean { export function isCacheStrictMatch(): boolean {
return getBooleanInput('gradle-home-cache-strict-match') return getBooleanInput('gradle-home-cache-strict-match')
} }

View File

@@ -38,6 +38,12 @@ async function addToPath(executable: string): Promise<string> {
} }
async function installGradle(version: string): Promise<string> { async function installGradle(version: string): Promise<string> {
const versionInfo = await resolveGradleVersion(version)
core.setOutput('gradle-version', versionInfo.version)
return installGradleVersion(versionInfo)
}
async function resolveGradleVersion(version: string): Promise<GradleVersionInfo> {
switch (version) { switch (version) {
case 'current': case 'current':
return gradleCurrent() return gradleCurrent()
@@ -55,36 +61,33 @@ async function installGradle(version: string): Promise<string> {
} }
} }
async function gradleCurrent(): Promise<string> { async function gradleCurrent(): Promise<GradleVersionInfo> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`) return await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`)
return installGradleVersion(versionInfo)
} }
async function gradleReleaseCandidate(): Promise<string> { async function gradleReleaseCandidate(): Promise<GradleVersionInfo> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`) const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`)
if (versionInfo && versionInfo.version && versionInfo.downloadUrl) { if (versionInfo && versionInfo.version && versionInfo.downloadUrl) {
return installGradleVersion(versionInfo) return versionInfo
} }
core.info('No current release-candidate found, will fallback to current') core.info('No current release-candidate found, will fallback to current')
return gradleCurrent() return gradleCurrent()
} }
async function gradleNightly(): Promise<string> { async function gradleNightly(): Promise<GradleVersionInfo> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`) return await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`)
return installGradleVersion(versionInfo)
} }
async function gradleReleaseNightly(): Promise<string> { async function gradleReleaseNightly(): Promise<GradleVersionInfo> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`) return await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`)
return installGradleVersion(versionInfo)
} }
async function gradle(version: string): Promise<string> { async function gradle(version: string): Promise<GradleVersionInfo> {
const versionInfo = await findGradleVersionDeclaration(version) const versionInfo = await findGradleVersionDeclaration(version)
if (!versionInfo) { if (!versionInfo) {
throw new Error(`Gradle version ${version} does not exists`) throw new Error(`Gradle version ${version} does not exists`)
} }
return installGradleVersion(versionInfo) return versionInfo
} }
async function gradleVersionDeclaration(url: string): Promise<GradleVersionInfo> { async function gradleVersionDeclaration(url: string): Promise<GradleVersionInfo> {

View File

@@ -82,7 +82,7 @@ def captureUsingBuildFinished(gradle, invocationId) {
def captureUsingBuildService(settings, invocationId) { def captureUsingBuildService(settings, invocationId) {
gradle.ext.invocationId = invocationId gradle.ext.invocationId = invocationId
apply from: 'build-result-capture-service.plugin.groovy' apply from: 'gradle-build-action.build-result-capture-service.plugin.groovy'
} }
class BuildResults { class BuildResults {

View File

@@ -31,7 +31,7 @@ if (isTopLevelBuild) {
println "Generating dependency graph into '${reportFile}'" println "Generating dependency graph into '${reportFile}'"
} }
apply from: 'github-dependency-graph-gradle-plugin-apply.groovy' apply from: 'gradle-build-action.github-dependency-graph-gradle-plugin-apply.groovy'
/** /**
* Using the supplied jobCorrelator value: * Using the supplied jobCorrelator value:

View File

@@ -0,0 +1,192 @@
import org.gradle.util.GradleVersion
// note that there is no mechanism to share code between the initscript{} block and the main script, so some logic is duplicated
// conditionally apply the GE / Build Scan plugin to the classpath so it can be applied to the build further down in this script
initscript {
def isTopLevelBuild = !gradle.parent
if (!isTopLevelBuild) {
return
}
def getInputParam = { String name ->
def envVarName = name.toUpperCase().replace('.', '_').replace('-', '_')
return System.getProperty(name) ?: System.getenv(envVarName)
}
// finish early if injection is disabled
def gradleInjectionEnabled = getInputParam("gradle-enterprise.injection-enabled")
if (gradleInjectionEnabled != "true") {
return
}
def pluginRepositoryUrl = getInputParam('gradle-enterprise.plugin-repository.url')
def gePluginVersion = getInputParam('gradle-enterprise.plugin.version')
def ccudPluginVersion = getInputParam('gradle-enterprise.ccud-plugin.version')
def atLeastGradle5 = GradleVersion.current() >= GradleVersion.version('5.0')
def atLeastGradle4 = GradleVersion.current() >= GradleVersion.version('4.0')
if (gePluginVersion || ccudPluginVersion && atLeastGradle4) {
pluginRepositoryUrl = pluginRepositoryUrl ?: 'https://plugins.gradle.org/m2'
logger.quiet("Gradle Enterprise plugins resolution: $pluginRepositoryUrl")
repositories {
maven { url pluginRepositoryUrl }
}
}
dependencies {
if (gePluginVersion) {
classpath atLeastGradle5 ?
"com.gradle:gradle-enterprise-gradle-plugin:$gePluginVersion" :
"com.gradle:build-scan-plugin:1.16"
}
if (ccudPluginVersion && atLeastGradle4) {
classpath "com.gradle:common-custom-user-data-gradle-plugin:$ccudPluginVersion"
}
}
}
def BUILD_SCAN_PLUGIN_ID = 'com.gradle.build-scan'
def BUILD_SCAN_PLUGIN_CLASS = 'com.gradle.scan.plugin.BuildScanPlugin'
def GRADLE_ENTERPRISE_PLUGIN_ID = 'com.gradle.enterprise'
def GRADLE_ENTERPRISE_PLUGIN_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin'
def GRADLE_ENTERPRISE_EXTENSION_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension'
def CI_AUTO_INJECTION_CUSTOM_VALUE_NAME = 'CI auto injection'
def CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE = 'gradle-build-action'
def CCUD_PLUGIN_ID = 'com.gradle.common-custom-user-data-gradle-plugin'
def CCUD_PLUGIN_CLASS = 'com.gradle.CommonCustomUserDataGradlePlugin'
def isTopLevelBuild = !gradle.parent
if (!isTopLevelBuild) {
return
}
def getInputParam = { String name ->
def envVarName = name.toUpperCase().replace('.', '_').replace('-', '_')
return System.getProperty(name) ?: System.getenv(envVarName)
}
// finish early if injection is disabled
def gradleInjectionEnabled = getInputParam("gradle-enterprise.injection-enabled")
if (gradleInjectionEnabled != "true") {
return
}
def geUrl = getInputParam('gradle-enterprise.url')
def geAllowUntrustedServer = Boolean.parseBoolean(getInputParam('gradle-enterprise.allow-untrusted-server'))
def geEnforceUrl = Boolean.parseBoolean(getInputParam('gradle-enterprise.enforce-url'))
def buildScanUploadInBackground = Boolean.parseBoolean(getInputParam('gradle-enterprise.build-scan.upload-in-background'))
def gePluginVersion = getInputParam('gradle-enterprise.plugin.version')
def ccudPluginVersion = getInputParam('gradle-enterprise.ccud-plugin.version')
def atLeastGradle4 = GradleVersion.current() >= GradleVersion.version('4.0')
// finish early if configuration parameters passed in via system properties are not valid/supported
if (ccudPluginVersion && isNotAtLeast(ccudPluginVersion, '1.7')) {
logger.warn("Common Custom User Data Gradle plugin must be at least 1.7. Configured version is $ccudPluginVersion.")
return
}
// register buildScanPublished listener and optionally apply the GE / Build Scan plugin
if (GradleVersion.current() < GradleVersion.version('6.0')) {
rootProject {
buildscript.configurations.getByName("classpath").incoming.afterResolve { ResolvableDependencies incoming ->
def resolutionResult = incoming.resolutionResult
if (gePluginVersion) {
def scanPluginComponent = resolutionResult.allComponents.find {
it.moduleVersion.with { group == "com.gradle" && (name == "build-scan-plugin" || name == "gradle-enterprise-gradle-plugin") }
}
if (!scanPluginComponent) {
logger.quiet("Applying $BUILD_SCAN_PLUGIN_CLASS via init script")
logger.quiet("Connection to Gradle Enterprise: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
applyPluginExternally(pluginManager, BUILD_SCAN_PLUGIN_CLASS)
buildScan.server = geUrl
buildScan.allowUntrustedServer = geAllowUntrustedServer
buildScan.publishAlways()
if (buildScan.metaClass.respondsTo(buildScan, 'setUploadInBackground', Boolean)) buildScan.uploadInBackground = buildScanUploadInBackground // uploadInBackground not available for build-scan-plugin 1.16
buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE
}
if (geUrl && geEnforceUrl) {
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
afterEvaluate {
logger.quiet("Enforcing Gradle Enterprise: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
buildScan.server = geUrl
buildScan.allowUntrustedServer = geAllowUntrustedServer
}
}
}
}
if (ccudPluginVersion && atLeastGradle4) {
def ccudPluginComponent = resolutionResult.allComponents.find {
it.moduleVersion.with { group == "com.gradle" && name == "common-custom-user-data-gradle-plugin" }
}
if (!ccudPluginComponent) {
logger.quiet("Applying $CCUD_PLUGIN_CLASS via init script")
pluginManager.apply(initscript.classLoader.loadClass(CCUD_PLUGIN_CLASS))
}
}
}
}
} else {
gradle.settingsEvaluated { settings ->
if (gePluginVersion) {
if (!settings.pluginManager.hasPlugin(GRADLE_ENTERPRISE_PLUGIN_ID)) {
logger.quiet("Applying $GRADLE_ENTERPRISE_PLUGIN_CLASS via init script")
logger.quiet("Connection to Gradle Enterprise: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
applyPluginExternally(settings.pluginManager, GRADLE_ENTERPRISE_PLUGIN_CLASS)
extensionsWithPublicType(settings, GRADLE_ENTERPRISE_EXTENSION_CLASS).collect { settings[it.name] }.each { ext ->
ext.server = geUrl
ext.allowUntrustedServer = geAllowUntrustedServer
ext.buildScan.publishAlways()
ext.buildScan.uploadInBackground = buildScanUploadInBackground
ext.buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE
}
}
if (geUrl && geEnforceUrl) {
extensionsWithPublicType(settings, GRADLE_ENTERPRISE_EXTENSION_CLASS).collect { settings[it.name] }.each { ext ->
logger.quiet("Enforcing Gradle Enterprise: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
ext.server = geUrl
ext.allowUntrustedServer = geAllowUntrustedServer
}
}
}
if (ccudPluginVersion) {
if (!settings.pluginManager.hasPlugin(CCUD_PLUGIN_ID)) {
logger.quiet("Applying $CCUD_PLUGIN_CLASS via init script")
settings.pluginManager.apply(initscript.classLoader.loadClass(CCUD_PLUGIN_CLASS))
}
}
}
}
void applyPluginExternally(PluginManager pluginManager, String pluginClassName) {
def externallyApplied = 'gradle.enterprise.externally-applied'
def oldValue = System.getProperty(externallyApplied)
System.setProperty(externallyApplied, 'true')
try {
pluginManager.apply(initscript.classLoader.loadClass(pluginClassName))
} finally {
if (oldValue == null) {
System.clearProperty(externallyApplied)
} else {
System.setProperty(externallyApplied, oldValue)
}
}
}
static def extensionsWithPublicType(def container, String publicType) {
container.extensions.extensionsSchema.elements.findAll { it.publicType.concreteClass.name == publicType }
}
static boolean isNotAtLeast(String versionUnderTest, String referenceVersion) {
GradleVersion.version(versionUnderTest) < GradleVersion.version(referenceVersion)
}

View File

@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionSha256Sum=03ec176d388f2aa99defcadc3ac6adf8dd2bce5145a129659537c0874dea5ad1 distributionSha256Sum=591855b517fc635b9e04de1d05d5e76ada3f89f5fc76f87978d1b245b4f69225
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@@ -83,7 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum

View File

@@ -16,6 +16,8 @@ import java.nio.file.Files
import java.util.zip.GZIPOutputStream import java.util.zip.GZIPOutputStream
class BaseInitScriptTest extends Specification { class BaseInitScriptTest extends Specification {
static final String GE_PLUGIN_VERSION = '3.14.1'
static final String CCUD_PLUGIN_VERSION = '1.11.1'
static final TestGradleVersion GRADLE_3_X = new TestGradleVersion(GradleVersion.version('3.5.1'), 7, 9) static final TestGradleVersion GRADLE_3_X = new TestGradleVersion(GradleVersion.version('3.5.1'), 7, 9)
static final TestGradleVersion GRADLE_4_X = new TestGradleVersion(GradleVersion.version('4.10.3'), 7, 10) static final TestGradleVersion GRADLE_4_X = new TestGradleVersion(GradleVersion.version('4.10.3'), 7, 10)
@@ -24,7 +26,7 @@ class BaseInitScriptTest extends Specification {
static final TestGradleVersion GRADLE_6_X = new TestGradleVersion(GradleVersion.version('6.9.4'), 8, 15) static final TestGradleVersion GRADLE_6_X = new TestGradleVersion(GradleVersion.version('6.9.4'), 8, 15)
static final TestGradleVersion GRADLE_7_X = new TestGradleVersion(GradleVersion.version('7.6.2'), 8, 19) static final TestGradleVersion GRADLE_7_X = new TestGradleVersion(GradleVersion.version('7.6.2'), 8, 19)
static final TestGradleVersion GRADLE_8_0 = new TestGradleVersion(GradleVersion.version('8.0.2'), 8, 19) static final TestGradleVersion GRADLE_8_0 = new TestGradleVersion(GradleVersion.version('8.0.2'), 8, 19)
static final TestGradleVersion GRADLE_8_X = new TestGradleVersion(GradleVersion.version('8.2.1'), 8, 19) static final TestGradleVersion GRADLE_8_X = new TestGradleVersion(GradleVersion.version('8.3'), 8, 19)
static final List<TestGradleVersion> ALL_VERSIONS = [ static final List<TestGradleVersion> ALL_VERSIONS = [
GRADLE_3_X, // First version where TestKit supports environment variables GRADLE_3_X, // First version where TestKit supports environment variables
@@ -126,12 +128,17 @@ class BaseInitScriptTest extends Specification {
buildFile << '' buildFile << ''
} }
def declareGePluginApplication(GradleVersion gradleVersion) { def declareGePluginApplication(GradleVersion gradleVersion, URI serverUrl = mockScansServer.address) {
settingsFile.text = maybeAddPluginsToSettings(gradleVersion) + settingsFile.text settingsFile.text = maybeAddPluginsToSettings(gradleVersion, null, serverUrl) + settingsFile.text
buildFile.text = maybeAddPluginsToRootProject(gradleVersion) + buildFile.text buildFile.text = maybeAddPluginsToRootProject(gradleVersion, null, serverUrl) + buildFile.text
} }
String maybeAddPluginsToSettings(GradleVersion gradleVersion) { def declareGePluginAndCcudPluginApplication(GradleVersion gradleVersion, URI serverUrl = mockScansServer.address) {
settingsFile.text = maybeAddPluginsToSettings(gradleVersion, CCUD_PLUGIN_VERSION, serverUrl) + settingsFile.text
buildFile.text = maybeAddPluginsToRootProject(gradleVersion, CCUD_PLUGIN_VERSION, serverUrl) + buildFile.text
}
String maybeAddPluginsToSettings(GradleVersion gradleVersion, String ccudPluginVersion, URI serverUri) {
if (gradleVersion < GradleVersion.version('5.0')) { if (gradleVersion < GradleVersion.version('5.0')) {
'' // applied in build.gradle '' // applied in build.gradle
} else if (gradleVersion < GradleVersion.version('6.0')) { } else if (gradleVersion < GradleVersion.version('6.0')) {
@@ -139,10 +146,11 @@ class BaseInitScriptTest extends Specification {
} else { } else {
""" """
plugins { plugins {
id 'com.gradle.enterprise' version '3.14.1' id 'com.gradle.enterprise' version '${GE_PLUGIN_VERSION}'
${ccudPluginVersion ? "id 'com.gradle.common-custom-user-data-gradle-plugin' version '$ccudPluginVersion'" : ""}
} }
gradleEnterprise { gradleEnterprise {
server = '$mockScansServer.address' server = '$serverUri'
buildScan { buildScan {
publishAlways() publishAlways()
} }
@@ -151,24 +159,26 @@ class BaseInitScriptTest extends Specification {
} }
} }
String maybeAddPluginsToRootProject(GradleVersion gradleVersion) { String maybeAddPluginsToRootProject(GradleVersion gradleVersion, String ccudPluginVersion, URI serverUrl) {
if (gradleVersion < GradleVersion.version('5.0')) { if (gradleVersion < GradleVersion.version('5.0')) {
""" """
plugins { plugins {
id 'com.gradle.build-scan' version '1.16' id 'com.gradle.build-scan' version '1.16'
${ccudPluginVersion ? "id 'com.gradle.common-custom-user-data-gradle-plugin' version '$ccudPluginVersion'" : ""}
} }
buildScan { buildScan {
server = '$mockScansServer.address' server = '$serverUrl'
publishAlways() publishAlways()
} }
""" """
} else if (gradleVersion < GradleVersion.version('6.0')) { } else if (gradleVersion < GradleVersion.version('6.0')) {
""" """
plugins { plugins {
id 'com.gradle.build-scan' version '3.14.1' id 'com.gradle.build-scan' version '${GE_PLUGIN_VERSION}'
${ccudPluginVersion ? "id 'com.gradle.common-custom-user-data-gradle-plugin' version '$ccudPluginVersion'" : ""}
} }
gradleEnterprise { gradleEnterprise {
server = '$mockScansServer.address' server = '$serverUrl'
buildScan { buildScan {
publishAlways() publishAlways()
} }

View File

@@ -5,7 +5,7 @@ import groovy.json.JsonSlurper
import static org.junit.Assume.assumeTrue import static org.junit.Assume.assumeTrue
class TestBuildResultRecorder extends BaseInitScriptTest { class TestBuildResultRecorder extends BaseInitScriptTest {
def initScript = 'build-result-capture.init.gradle' def initScript = 'gradle-build-action.build-result-capture.init.gradle'
def "produces build results file for build with #testGradleVersion"() { def "produces build results file for build with #testGradleVersion"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm assumeTrue testGradleVersion.compatibleWithCurrentJvm

View File

@@ -3,7 +3,7 @@ package com.gradle.gradlebuildaction
import static org.junit.Assume.assumeTrue import static org.junit.Assume.assumeTrue
class TestDependencyGraph extends BaseInitScriptTest { class TestDependencyGraph extends BaseInitScriptTest {
def initScript = 'github-dependency-graph.init.gradle' def initScript = 'gradle-build-action.github-dependency-graph.init.gradle'
static final List<TestGradleVersion> NO_DEPENDENCY_GRAPH_VERSIONS = [GRADLE_3_X, GRADLE_4_X] static final List<TestGradleVersion> NO_DEPENDENCY_GRAPH_VERSIONS = [GRADLE_3_X, GRADLE_4_X]
static final List<TestGradleVersion> DEPENDENCY_GRAPH_VERSIONS = ALL_VERSIONS - NO_DEPENDENCY_GRAPH_VERSIONS static final List<TestGradleVersion> DEPENDENCY_GRAPH_VERSIONS = ALL_VERSIONS - NO_DEPENDENCY_GRAPH_VERSIONS
@@ -32,20 +32,20 @@ class TestDependencyGraph extends BaseInitScriptTest {
assert gitHubOutputFile.text == "dependency-graph-file=${reportFile.absolutePath}\n" assert gitHubOutputFile.text == "dependency-graph-file=${reportFile.absolutePath}\n"
where: where:
testGradleVersion << GRADLE_8_X testGradleVersion << [GRADLE_8_X]
} }
// Dependency-graph plugin doesn't support config-cache for 8.0 of Gradle
def "produces dependency graph with configuration-cache on latest Gradle"() { def "produces dependency graph with configuration-cache on latest Gradle"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm assumeTrue testGradleVersion.compatibleWithCurrentJvm
when: when:
run(['help'], initScript, testGradleVersion.gradleVersion, [], envVars) run(['help', '--configuration-cache'], initScript, testGradleVersion.gradleVersion, [], envVars)
then: then:
assert reportFile.exists() assert reportFile.exists()
where: where:
// Dependency-graph plugin doesn't support config-cache for 8.0 of Gradle
testGradleVersion << [GRADLE_8_X] testGradleVersion << [GRADLE_8_X]
} }

View File

@@ -0,0 +1,401 @@
package com.gradle.gradlebuildaction
import org.gradle.testkit.runner.BuildResult
import org.gradle.util.GradleVersion
import static org.junit.Assume.assumeTrue
class TestGradleEnterpriseInjection extends BaseInitScriptTest {
static final List<TestGradleVersion> CCUD_COMPATIBLE_VERSIONS = ALL_VERSIONS - [GRADLE_3_X]
def initScript = 'gradle-build-action.inject-gradle-enterprise.init.gradle'
private static final GradleVersion GRADLE_6 = GradleVersion.version('6.0')
def "does not apply GE plugins when not requested"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
def result = run([], initScript, testGradleVersion.gradleVersion)
then:
outputMissesGePluginApplicationViaInitScript(result)
outputMissesCcudPluginApplicationViaInitScript(result)
where:
testGradleVersion << ALL_VERSIONS
}
def "does not override GE plugin when already defined in project"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
given:
declareGePluginApplication(testGradleVersion.gradleVersion)
when:
def result = run(testGradleVersion, testConfig())
then:
outputMissesGePluginApplicationViaInitScript(result)
outputMissesCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << ALL_VERSIONS
}
def "applies GE plugin via init script when not defined in project"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
def result = run(testGradleVersion, testConfig())
then:
outputContainsGePluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
outputMissesCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << ALL_VERSIONS
}
def "applies GE and CCUD plugins via init script when not defined in project"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
def result = run(testGradleVersion, testConfig().withCCUDPlugin())
then:
outputContainsGePluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
outputContainsCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << CCUD_COMPATIBLE_VERSIONS
}
def "applies CCUD plugin via init script where GE plugin already applied"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
given:
declareGePluginApplication(testGradleVersion.gradleVersion)
when:
def result = run(testGradleVersion, testConfig().withCCUDPlugin())
then:
outputMissesGePluginApplicationViaInitScript(result)
outputContainsCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << CCUD_COMPATIBLE_VERSIONS
}
def "does not override CCUD plugin when already defined in project"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
given:
declareGePluginAndCcudPluginApplication(testGradleVersion.gradleVersion)
when:
def result = run(testGradleVersion, testConfig().withCCUDPlugin())
then:
outputMissesGePluginApplicationViaInitScript(result)
outputMissesCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << CCUD_COMPATIBLE_VERSIONS
}
def "ignores GE URL and allowUntrustedServer when GE plugin is not applied by the init script"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
given:
declareGePluginApplication(testGradleVersion.gradleVersion)
when:
def config = testConfig().withServer(URI.create('https://ge-server.invalid'))
def result = run(testGradleVersion, config)
then:
outputMissesGePluginApplicationViaInitScript(result)
outputMissesCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << ALL_VERSIONS
}
def "configures GE URL and allowUntrustedServer when GE plugin is applied by the init script"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
def config = testConfig().withServer(mockScansServer.address)
def result = run(testGradleVersion, config)
then:
outputContainsGePluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
outputContainsGeConnectionInfo(result, mockScansServer.address.toString(), true)
outputMissesCcudPluginApplicationViaInitScript(result)
outputContainsPluginRepositoryInfo(result, 'https://plugins.gradle.org/m2')
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << ALL_VERSIONS
}
def "enforces GE URL and allowUntrustedServer in project if enforce url parameter is enabled"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
given:
declareGePluginApplication(testGradleVersion.gradleVersion, URI.create('https://ge-server.invalid'))
when:
def config = testConfig().withServer(mockScansServer.address, true)
def result = run(testGradleVersion, config)
then:
outputMissesGePluginApplicationViaInitScript(result)
outputMissesCcudPluginApplicationViaInitScript(result)
and:
outputEnforcesGeUrl(result, mockScansServer.address.toString(), true)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << ALL_VERSIONS
}
def "can configure alternative repository for plugins when GE plugin is applied by the init script"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
def config = testConfig().withPluginRepository(new URI('https://plugins.grdev.net/m2'))
def result = run(testGradleVersion, config)
then:
outputContainsGePluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
outputContainsGeConnectionInfo(result, mockScansServer.address.toString(), true)
outputMissesCcudPluginApplicationViaInitScript(result)
outputContainsPluginRepositoryInfo(result, 'https://plugins.grdev.net/m2')
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << ALL_VERSIONS
}
def "stops gracefully when requested CCUD plugin version is <1.7"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
def config = testConfig().withCCUDPlugin("1.6.6")
def result = run(testGradleVersion, config)
then:
outputMissesGePluginApplicationViaInitScript(result)
outputMissesCcudPluginApplicationViaInitScript(result)
result.output.contains('Common Custom User Data Gradle plugin must be at least 1.7. Configured version is 1.6.6.')
where:
testGradleVersion << ALL_VERSIONS
}
def "can configure GE via CCUD system property overrides when CCUD plugin is inject via init script"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
def config = testConfig().withCCUDPlugin().withServer(URI.create('https://ge-server.invalid'))
def result = run(testGradleVersion, config, ["help", "-Dgradle.enterprise.url=${mockScansServer.address}".toString()])
then:
outputContainsGePluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
outputContainsCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << CCUD_COMPATIBLE_VERSIONS
}
def "init script is configuration cache compatible"() {
assumeTrue testGradleVersion.compatibleWithCurrentJvm
when:
def config = testConfig().withCCUDPlugin()
def result = run(testGradleVersion, config, ["help", "--configuration-cache"])
then:
outputContainsGePluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
outputContainsCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
when:
result = run(testGradleVersion, config, ["help", "--configuration-cache"])
then:
outputMissesGePluginApplicationViaInitScript(result)
outputMissesCcudPluginApplicationViaInitScript(result)
and:
outputContainsBuildScanUrl(result)
where:
testGradleVersion << CONFIGURATION_CACHE_VERSIONS
}
void outputContainsBuildScanUrl(BuildResult result) {
def message = "Publishing build scan...\n${mockScansServer.address}s/$PUBLIC_BUILD_SCAN_ID"
assert result.output.contains(message)
assert 1 == result.output.count(message)
}
void outputContainsGePluginApplicationViaInitScript(BuildResult result, GradleVersion gradleVersion) {
def pluginApplicationLogMsgGradle4And5 = "Applying com.gradle.scan.plugin.BuildScanPlugin via init script"
def pluginApplicationLogMsgGradle6AndHigher = "Applying com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin via init script"
if (gradleVersion < GRADLE_6) {
assert result.output.contains(pluginApplicationLogMsgGradle4And5)
assert 1 == result.output.count(pluginApplicationLogMsgGradle4And5)
assert !result.output.contains(pluginApplicationLogMsgGradle6AndHigher)
} else {
assert result.output.contains(pluginApplicationLogMsgGradle6AndHigher)
assert 1 == result.output.count(pluginApplicationLogMsgGradle6AndHigher)
assert !result.output.contains(pluginApplicationLogMsgGradle4And5)
}
}
void outputMissesGePluginApplicationViaInitScript(BuildResult result) {
def pluginApplicationLogMsgGradle4And5 = "Applying com.gradle.scan.plugin.BuildScanPlugin via init script"
def pluginApplicationLogMsgGradle6AndHigher = "Applying com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin via init script"
assert !result.output.contains(pluginApplicationLogMsgGradle4And5)
assert !result.output.contains(pluginApplicationLogMsgGradle6AndHigher)
}
void outputContainsCcudPluginApplicationViaInitScript(BuildResult result) {
def pluginApplicationLogMsg = "Applying com.gradle.CommonCustomUserDataGradlePlugin via init script"
assert result.output.contains(pluginApplicationLogMsg)
assert 1 == result.output.count(pluginApplicationLogMsg)
}
void outputMissesCcudPluginApplicationViaInitScript(BuildResult result) {
def pluginApplicationLogMsg = "Applying com.gradle.CommonCustomUserDataGradlePlugin via init script"
assert !result.output.contains(pluginApplicationLogMsg)
}
void outputContainsGeConnectionInfo(BuildResult result, String geUrl, boolean geAllowUntrustedServer) {
def geConnectionInfo = "Connection to Gradle Enterprise: $geUrl, allowUntrustedServer: $geAllowUntrustedServer"
assert result.output.contains(geConnectionInfo)
assert 1 == result.output.count(geConnectionInfo)
}
void outputContainsPluginRepositoryInfo(BuildResult result, String gradlePluginRepositoryUrl) {
def repositoryInfo = "Gradle Enterprise plugins resolution: ${gradlePluginRepositoryUrl}"
assert result.output.contains(repositoryInfo)
assert 1 == result.output.count(repositoryInfo)
}
void outputEnforcesGeUrl(BuildResult result, String geUrl, boolean geAllowUntrustedServer) {
def enforceUrl = "Enforcing Gradle Enterprise: $geUrl, allowUntrustedServer: $geAllowUntrustedServer"
assert result.output.contains(enforceUrl)
assert 1 == result.output.count(enforceUrl)
}
private BuildResult run(TestGradleVersion testGradleVersion, TestConfig config, List<String> args = ["help"]) {
if (testKitSupportsEnvVars(testGradleVersion.gradleVersion)) {
return run(args, initScript, testGradleVersion.gradleVersion, [], config.envVars)
} else {
return run(args, initScript, testGradleVersion.gradleVersion, config.jvmArgs, [:])
}
}
private boolean testKitSupportsEnvVars(GradleVersion gradleVersion) {
// TestKit supports env vars for Gradle 3.5+, except on M1 Mac where only 6.9+ is supported
def isM1Mac = System.getProperty("os.arch") == "aarch64"
if (isM1Mac) {
return gradleVersion >= GRADLE_6_X.gradleVersion
} else {
return gradleVersion >= GRADLE_3_X.gradleVersion
}
}
private TestConfig testConfig() {
new TestConfig()
}
class TestConfig {
String serverUrl = mockScansServer.address.toString()
boolean enforceUrl = false
String ccudPluginVersion = null
String pluginRepositoryUrl = null
TestConfig withCCUDPlugin(String version = CCUD_PLUGIN_VERSION) {
ccudPluginVersion = version
return this
}
TestConfig withServer(URI url, boolean enforceUrl = false) {
serverUrl = url.toASCIIString()
this.enforceUrl = enforceUrl
return this
}
TestConfig withPluginRepository(URI pluginRepositoryUrl) {
this.pluginRepositoryUrl = pluginRepositoryUrl
return this
}
def getEnvVars() {
Map<String, String> envVars = [
GRADLE_ENTERPRISE_INJECTION_ENABLED: "true",
GRADLE_ENTERPRISE_URL: serverUrl,
GRADLE_ENTERPRISE_ALLOW_UNTRUSTED_SERVER: "true",
GRADLE_ENTERPRISE_PLUGIN_VERSION: GE_PLUGIN_VERSION,
GRADLE_ENTERPRISE_BUILD_SCAN_UPLOAD_IN_BACKGROUND: "true" // Need to upload in background since our Mock server doesn't cope with foreground upload
]
if (enforceUrl) envVars.put("GRADLE_ENTERPRISE_ENFORCE_URL", "true")
if (ccudPluginVersion != null) envVars.put("GRADLE_ENTERPRISE_CCUD_PLUGIN_VERSION", ccudPluginVersion)
if (pluginRepositoryUrl != null) envVars.put("GRADLE_ENTERPRISE_PLUGIN_REPOSITORY_URL", pluginRepositoryUrl)
return envVars
}
def getJvmArgs() {
List<String> jvmArgs = [
"-Dgradle-enterprise.injection-enabled=true",
"-Dgradle-enterprise.url=$serverUrl",
"-Dgradle-enterprise.allow-untrusted-server=true",
"-Dgradle-enterprise.plugin.version=$GE_PLUGIN_VERSION",
"-Dgradle-enterprise.build-scan.upload-in-background=true"
]
if (enforceUrl) jvmArgs.add("-Dgradle-enterprise.enforce-url=true")
if (ccudPluginVersion != null) jvmArgs.add("-Dgradle-enterprise.ccud-plugin.version=$ccudPluginVersion")
if (pluginRepositoryUrl != null) jvmArgs.add("-Dgradle-enterprise.plugin-repository.url=$pluginRepositoryUrl")
return jvmArgs.collect { it.toString() } // Convert from GStrings
}
}
}

View File

@@ -49,7 +49,7 @@ test('will cleanup unused gradle versions', async () => {
const gradle802 = path.resolve(gradleUserHome, "caches/8.0.2") const gradle802 = path.resolve(gradleUserHome, "caches/8.0.2")
const wrapper802 = path.resolve(gradleUserHome, "wrapper/dists/gradle-8.0.2-bin") const wrapper802 = path.resolve(gradleUserHome, "wrapper/dists/gradle-8.0.2-bin")
const gradleCurrent = path.resolve(gradleUserHome, "caches/8.2.1") const gradleCurrent = path.resolve(gradleUserHome, "caches/8.3")
expect(fs.existsSync(gradle802)).toBe(true) expect(fs.existsSync(gradle802)).toBe(true)
expect(fs.existsSync(wrapper802)).toBe(true) expect(fs.existsSync(wrapper802)).toBe(true)