diff --git a/src/cache-base.ts b/src/cache-base.ts index c6b5e953..ce035642 100644 --- a/src/cache-base.ts +++ b/src/cache-base.ts @@ -199,7 +199,7 @@ export class GradleStateCache { 'gradle-build-action.inject-gradle-enterprise.init.gradle' ] for (const initScriptFilename of initScriptFilenames) { - const initScriptContent = this.readInitScriptAsString(initScriptFilename) + const initScriptContent = this.readResourceFileAsString('init-scripts', initScriptFilename) const initScriptPath = path.resolve(initScriptsDir, initScriptFilename) fs.writeFileSync(initScriptPath, initScriptContent) } @@ -209,16 +209,16 @@ export class GradleStateCache { const toolchainXmlTarget = path.resolve(m2dir, 'toolchains.xml') if (!fs.existsSync(toolchainXmlTarget)) { fs.mkdirSync(m2dir, {recursive: true}) - const toolchainContent = this.readInitScriptAsString('toolchains.xml') + const toolchainContent = this.readResourceFileAsString('toolchains.xml') fs.writeFileSync(toolchainXmlTarget, toolchainContent) core.info(`Wrote default JDK locations to ${toolchainXmlTarget}`) } } - private readInitScriptAsString(resource: string): string { + private readResourceFileAsString(...paths: string[]): string { // Resolving relative to __dirname will allow node to find the resource at runtime - const absolutePath = path.resolve(__dirname, '..', '..', 'src', 'resources', 'init-scripts', resource) + const absolutePath = path.resolve(__dirname, '..', '..', 'src', 'resources', ...paths) return fs.readFileSync(absolutePath, 'utf8') } diff --git a/src/resources/init-scripts/toolchains.xml b/src/resources/toolchains.xml similarity index 100% rename from src/resources/init-scripts/toolchains.xml rename to src/resources/toolchains.xml