mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-26 02:52:09 +00:00
30 lines
868 B
TypeScript
30 lines
868 B
TypeScript
import path from 'path'
|
|
import fs from 'fs'
|
|
import {AbstractCache} from './cache-utils'
|
|
|
|
// TODO: Maybe allow the user to override / tweak this set
|
|
const PATHS_TO_CACHE = [
|
|
'configuration-cache' // Only configuration-cache is stored at present
|
|
]
|
|
|
|
export class ProjectDotGradleCache extends AbstractCache {
|
|
private rootDir: string
|
|
constructor(rootDir: string) {
|
|
super('project', 'Project .gradle directory')
|
|
this.rootDir = rootDir
|
|
}
|
|
|
|
protected cacheOutputExists(): boolean {
|
|
const dir = this.getProjectDotGradleDir()
|
|
return fs.existsSync(dir)
|
|
}
|
|
|
|
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')
|
|
}
|
|
}
|