mirror of
https://github.com/gradle/actions
synced 2024-11-27 11:52:24 +00:00
Cache wrapper install when gradle-executable points to a wrapper
This commit is contained in:
parent
e8885a31b8
commit
692fda9de7
4 changed files with 14 additions and 7 deletions
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -9,11 +9,13 @@ const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH'
|
||||||
const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
|
const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
|
||||||
|
|
||||||
export async function restoreCachedWrapperDist(
|
export async function restoreCachedWrapperDist(
|
||||||
executableDirectory: string
|
gradlewDirectory: string | null
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
if (gradlewDirectory == null) return
|
||||||
|
|
||||||
const wrapperSlug = extractGradleWrapperSlugFrom(
|
const wrapperSlug = extractGradleWrapperSlugFrom(
|
||||||
path.join(
|
path.join(
|
||||||
path.resolve(executableDirectory),
|
path.resolve(gradlewDirectory),
|
||||||
'gradle/wrapper/gradle-wrapper.properties'
|
'gradle/wrapper/gradle-wrapper.properties'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
11
src/main.ts
11
src/main.ts
|
@ -40,18 +40,23 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
||||||
|
|
||||||
const gradleExecutable = inputOrNull('gradle-executable')
|
const gradleExecutable = inputOrNull('gradle-executable')
|
||||||
if (gradleExecutable !== null) {
|
if (gradleExecutable !== null) {
|
||||||
|
if (gradleExecutable.endsWith(gradlew.wrapperFilename())) {
|
||||||
|
await cache.restoreCachedWrapperDist(
|
||||||
|
path.resolve(gradleExecutable, '..')
|
||||||
|
)
|
||||||
|
}
|
||||||
return path.resolve(baseDirectory, gradleExecutable)
|
return path.resolve(baseDirectory, gradleExecutable)
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapperDirectory = inputOrNull('wrapper-directory')
|
const wrapperDirectory = inputOrNull('wrapper-directory')
|
||||||
const executableDirectory =
|
const gradlewDirectory =
|
||||||
wrapperDirectory !== null
|
wrapperDirectory !== null
|
||||||
? path.join(baseDirectory, wrapperDirectory)
|
? path.join(baseDirectory, wrapperDirectory)
|
||||||
: baseDirectory
|
: baseDirectory
|
||||||
|
|
||||||
await cache.restoreCachedWrapperDist(executableDirectory)
|
await cache.restoreCachedWrapperDist(gradlewDirectory)
|
||||||
|
|
||||||
return path.resolve(executableDirectory, gradlew.wrapperFilename())
|
return path.resolve(gradlewDirectory, gradlew.wrapperFilename())
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveBuildRootDirectory(baseDirectory: string): string {
|
function resolveBuildRootDirectory(baseDirectory: string): string {
|
||||||
|
|
Loading…
Reference in a new issue