mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-21 15:51:03 -05:00
Inform Gradle where to locate pre-installed JDKs
This commit is contained in:
parent
b17d107b8c
commit
a07019c726
2 changed files with 40 additions and 0 deletions
|
@ -80,3 +80,27 @@ jobs:
|
|||
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
|
||||
grep -q 'org.gradle.java.installations.fromEnv=JAVA_HOME' && exit 1
|
||||
|
|
|
@ -172,6 +172,22 @@ export class GradleStateCache {
|
|||
}
|
||||
|
||||
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 = [
|
||||
'build-result-capture.init.gradle',
|
||||
'build-result-capture-service.plugin.groovy',
|
||||
|
|
Loading…
Reference in a new issue