gradle-build-action/src/cache-project-dot-gradle.ts

28 lines
828 B
TypeScript
Raw Normal View History

import path from 'path'
import {AbstractCache} from './cache-base'
// TODO: Maybe allow the user to override / tweak this set
const PATHS_TO_CACHE = [
'configuration-cache' // Only configuration-cache is stored at present
]
/**
* A simple cache that saves and restores the '.gradle/configuration-cache' directory in the project root.
*/
export class ProjectDotGradleCache extends AbstractCache {
private rootDir: string
constructor(rootDir: string) {
2021-10-30 07:39:21 -06:00
super('project', 'Project configuration cache')
this.rootDir = rootDir
}
protected getCachePath(): string[] {
const dir = this.getProjectDotGradleDir()
return PATHS_TO_CACHE.map(x => path.resolve(dir, x))
}
private getProjectDotGradleDir(): string {
return path.resolve(this.rootDir, '.gradle')
}
}