Avoid unnecessary resolve of installed Gradle

This commit is contained in:
daz 2024-01-04 13:21:21 -07:00
parent 4dda5928c7
commit 70af846d72
No known key found for this signature in database

View file

@ -8,7 +8,6 @@ import * as toolCache from '@actions/tool-cache'
import * as gradlew from './gradlew' import * as gradlew from './gradlew'
import * as params from './input-params' import * as params from './input-params'
import * as layout from './repository-layout'
import {handleCacheFailure, isCacheDisabled, isCacheReadOnly} from './cache-utils' import {handleCacheFailure, isCacheDisabled, isCacheReadOnly} from './cache-utils'
const gradleVersionsBaseUrl = 'https://services.gradle.org/versions' const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'
@ -20,13 +19,12 @@ const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'
export async function provisionGradle(): Promise<string | undefined> { export async function provisionGradle(): Promise<string | undefined> {
const gradleVersion = params.getGradleVersion() const gradleVersion = params.getGradleVersion()
if (gradleVersion !== '' && gradleVersion !== 'wrapper') { if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
return addToPath(path.resolve(await installGradle(gradleVersion))) return addToPath(await installGradle(gradleVersion))
} }
const gradleExecutable = params.getGradleExecutable() const gradleExecutable = params.getGradleExecutable()
if (gradleExecutable !== '') { if (gradleExecutable !== '') {
const workspaceDirectory = layout.workspaceDirectory() return addToPath(gradleExecutable)
return addToPath(path.resolve(workspaceDirectory, gradleExecutable))
} }
return undefined return undefined