mirror of
https://github.com/gradle/gradle-build-action
synced 2024-12-18 06:12:23 +00:00
Move bundle metadata files out of caches
directory
Instead, use a separate '.gradle-build-action' directory for bundle metadata files. This directory is always part of the cache-path.
This commit is contained in:
parent
614d8770a4
commit
4cf255df10
1 changed files with 15 additions and 8 deletions
|
@ -12,6 +12,8 @@ import {
|
||||||
tryDelete
|
tryDelete
|
||||||
} from './cache-utils'
|
} from './cache-utils'
|
||||||
|
|
||||||
|
const META_FILE_DIR = '.gradle-build-action'
|
||||||
|
|
||||||
export class GradleUserHomeCache extends AbstractCache {
|
export class GradleUserHomeCache extends AbstractCache {
|
||||||
private gradleUserHome: string
|
private gradleUserHome: string
|
||||||
|
|
||||||
|
@ -65,11 +67,7 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getBundleMetaFile(name: string): string {
|
private getBundleMetaFile(name: string): string {
|
||||||
return path.resolve(
|
return path.resolve(this.gradleUserHome, META_FILE_DIR, `${name}.cache`)
|
||||||
this.gradleUserHome,
|
|
||||||
'caches',
|
|
||||||
`.gradle-build-action.${name}.cache`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeSave(): Promise<void> {
|
async beforeSave(): Promise<void> {
|
||||||
|
@ -142,9 +140,7 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
} else {
|
} else {
|
||||||
core.info(`Caching ${bundle} with cache key: ${cacheKey}`)
|
core.info(`Caching ${bundle} with cache key: ${cacheKey}`)
|
||||||
await this.saveCache([artifactPath], cacheKey)
|
await this.saveCache([artifactPath], cacheKey)
|
||||||
|
this.writeBundleMetaFile(bundleMetaFile, cacheKey)
|
||||||
this.debug(`Writing cache metafile: ${bundleMetaFile}`)
|
|
||||||
fs.writeFileSync(bundleMetaFile, cacheKey)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const file of bundleFiles) {
|
for (const file of bundleFiles) {
|
||||||
|
@ -166,6 +162,17 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
return `${cacheKeyPrefix}${bundle}-${key}`
|
return `${cacheKeyPrefix}${bundle}-${key}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private writeBundleMetaFile(metaFile: string, cacheKey: string): void {
|
||||||
|
this.debug(`Writing bundle metafile: ${metaFile}`)
|
||||||
|
|
||||||
|
const dirName = path.dirname(metaFile)
|
||||||
|
if (!fs.existsSync(dirName)) {
|
||||||
|
fs.mkdirSync(dirName)
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(metaFile, cacheKey)
|
||||||
|
}
|
||||||
|
|
||||||
protected determineGradleUserHome(rootDir: string): string {
|
protected determineGradleUserHome(rootDir: string): string {
|
||||||
const customGradleUserHome = process.env['GRADLE_USER_HOME']
|
const customGradleUserHome = process.env['GRADLE_USER_HOME']
|
||||||
if (customGradleUserHome) {
|
if (customGradleUserHome) {
|
||||||
|
|
Loading…
Reference in a new issue