mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-06-05 07:46:11 +02:00
Allow cache-exclude-paths to be configured for action
All excluded paths are deleted prior to caching the Gradle User Home.
This commit is contained in:
parent
9c95294209
commit
1113cb87cb
2 changed files with 32 additions and 5 deletions
|
@ -74,12 +74,27 @@ export class GradleUserHomeCache extends AbstractCache {
|
|||
|
||||
async beforeSave(): Promise<void> {
|
||||
await this.reportGradleUserHomeSize('before saving common artifacts')
|
||||
this.removeExcludedPaths()
|
||||
await this.saveArtifactBundles()
|
||||
await this.reportGradleUserHomeSize(
|
||||
'after saving common artifacts (./wrapper dir is not cached)'
|
||||
"after saving common artifacts (only 'caches' and 'notifications' will be stored)"
|
||||
)
|
||||
}
|
||||
|
||||
private removeExcludedPaths(): void {
|
||||
const rawPaths: string[] = JSON.parse(
|
||||
core.getInput('cache-exclude-paths')
|
||||
)
|
||||
const resolvedPaths = rawPaths.map(x =>
|
||||
path.resolve(this.gradleUserHome, x)
|
||||
)
|
||||
|
||||
for (const p of resolvedPaths) {
|
||||
this.debug(`Deleting excluded path: ${p}`)
|
||||
tryDelete(p)
|
||||
}
|
||||
}
|
||||
|
||||
private async saveArtifactBundles(): Promise<void> {
|
||||
const processes: Promise<void>[] = []
|
||||
for (const [bundle, pattern] of this.getArtifactBundles()) {
|
||||
|
@ -177,9 +192,7 @@ export class GradleUserHomeCache extends AbstractCache {
|
|||
private resolveCachePath(rawPath: string): string {
|
||||
if (rawPath.startsWith('!')) {
|
||||
const resolved = this.resolveCachePath(rawPath.substring(1))
|
||||
const negated = `!${resolved}`
|
||||
this.debug(`Negate cache path: ${negated}`)
|
||||
return negated
|
||||
return `!${resolved}`
|
||||
}
|
||||
return path.resolve(this.gradleUserHome, rawPath)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue