mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-27 01:59:02 +08:00
Fix check for pre-existing Gradle User Home
This commit is contained in:
parent
50ca2bca83
commit
7dee0f45c2
@ -100,9 +100,14 @@ export class GradleStateCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cacheOutputExists(): boolean {
|
cacheOutputExists(): boolean {
|
||||||
// Need to check for 'caches' directory to avoid incorrect detection on MacOS agents
|
|
||||||
const paths = this.getCachePath()
|
const paths = this.getCachePath()
|
||||||
return paths.some(x => fs.existsSync(x))
|
for (const p of paths) {
|
||||||
|
if (fs.existsSync(p)) {
|
||||||
|
cacheDebug(`Cache output exists at ${p}`)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,20 +15,24 @@ export async function restore(gradleUserHome: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
core.exportVariable(CACHE_RESTORED_VAR, true)
|
core.exportVariable(CACHE_RESTORED_VAR, true)
|
||||||
|
|
||||||
// Initialize the Gradle User Home even when caching is disabled.
|
|
||||||
const gradleStateCache = new GradleStateCache(gradleUserHome)
|
const gradleStateCache = new GradleStateCache(gradleUserHome)
|
||||||
gradleStateCache.init()
|
|
||||||
|
|
||||||
if (isCacheDisabled()) {
|
if (isCacheDisabled()) {
|
||||||
core.info('Cache is disabled: will not restore state from previous builds.')
|
core.info('Cache is disabled: will not restore state from previous builds.')
|
||||||
|
// Initialize the Gradle User Home even when caching is disabled.
|
||||||
|
gradleStateCache.init()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gradleStateCache.cacheOutputExists()) {
|
if (gradleStateCache.cacheOutputExists()) {
|
||||||
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.
|
||||||
|
gradleStateCache.init()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gradleStateCache.init()
|
||||||
|
|
||||||
await core.group('Restore Gradle state from cache', async () => {
|
await core.group('Restore Gradle state from cache', async () => {
|
||||||
core.saveState(GRADLE_USER_HOME, gradleUserHome)
|
core.saveState(GRADLE_USER_HOME, gradleUserHome)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user