mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-20 07:08:56 +08:00
Consolidate cache-enabled options
This commit is contained in:
@@ -1,26 +1,31 @@
|
||||
import * as cacheGradleUserHome from './cache-gradle-user-home'
|
||||
import * as cacheProjectDotGradle from './cache-project-dot-gradle'
|
||||
import * as core from '@actions/core'
|
||||
import {isCacheReadEnabled, isCacheSaveEnabled} from './cache-utils'
|
||||
|
||||
const BUILD_ROOT_DIR = 'BUILD_ROOT_DIR'
|
||||
|
||||
export async function restore(buildRootDirectory: string): Promise<void> {
|
||||
core.startGroup('Restore Gradle User Home from cache')
|
||||
await cacheGradleUserHome.restore()
|
||||
core.endGroup()
|
||||
if (!isCacheReadEnabled('gradle')) {
|
||||
core.debug('Cache read disabled')
|
||||
return
|
||||
}
|
||||
|
||||
core.startGroup('Restore project .gradle directory from cache')
|
||||
core.startGroup('Restore Gradle state from cache')
|
||||
await cacheGradleUserHome.restore()
|
||||
core.saveState(BUILD_ROOT_DIR, buildRootDirectory)
|
||||
await cacheProjectDotGradle.restore(buildRootDirectory)
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
export async function save(): Promise<void> {
|
||||
core.startGroup('Cache Gradle User Home')
|
||||
await cacheGradleUserHome.save()
|
||||
core.endGroup()
|
||||
if (!isCacheSaveEnabled('gradle')) {
|
||||
core.debug('Cache save disabled')
|
||||
return
|
||||
}
|
||||
|
||||
core.startGroup('Cache project .gradle directory')
|
||||
core.startGroup('Caching Gradle state')
|
||||
await cacheGradleUserHome.save()
|
||||
const buildRootDirectory = core.getState(BUILD_ROOT_DIR)
|
||||
await cacheProjectDotGradle.save(buildRootDirectory)
|
||||
core.endGroup()
|
||||
|
Reference in New Issue
Block a user