2021-08-20 13:01:43 -06:00
|
|
|
import path from 'path'
|
|
|
|
import fs from 'fs'
|
2021-09-06 11:16:08 -06:00
|
|
|
import {AbstractCache} from './cache-utils'
|
2021-08-20 13:01:43 -06:00
|
|
|
|
2021-09-13 11:47:59 -06:00
|
|
|
// TODO: Maybe allow the user to override / tweak this set
|
2021-08-20 13:01:43 -06:00
|
|
|
const PATHS_TO_CACHE = [
|
|
|
|
'configuration-cache' // Only configuration-cache is stored at present
|
|
|
|
]
|
|
|
|
|
2021-09-06 11:16:08 -06:00
|
|
|
export class ProjectDotGradleCache extends AbstractCache {
|
|
|
|
private rootDir: string
|
|
|
|
constructor(rootDir: string) {
|
|
|
|
super('project', 'Project .gradle directory')
|
|
|
|
this.rootDir = rootDir
|
2021-08-20 13:01:43 -06:00
|
|
|
}
|
|
|
|
|
2021-09-06 11:16:08 -06:00
|
|
|
protected cacheOutputExists(): boolean {
|
|
|
|
const dir = this.getProjectDotGradleDir()
|
|
|
|
return fs.existsSync(dir)
|
2021-08-20 13:01:43 -06:00
|
|
|
}
|
|
|
|
|
2021-09-06 11:16:08 -06:00
|
|
|
protected getCachePath(): string[] {
|
|
|
|
const dir = this.getProjectDotGradleDir()
|
|
|
|
return PATHS_TO_CACHE.map(x => path.resolve(dir, x))
|
2021-08-20 13:01:43 -06:00
|
|
|
}
|
|
|
|
|
2021-09-06 11:16:08 -06:00
|
|
|
private getProjectDotGradleDir(): string {
|
|
|
|
return path.resolve(this.rootDir, '.gradle')
|
2021-08-20 13:01:43 -06:00
|
|
|
}
|
|
|
|
}
|