Skip to content

Commit

Permalink
Move toolchains.xml out of 'init-scripts' dir
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Jan 4, 2024
1 parent 915b7c5 commit 76f88a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cache-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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')
}

Expand Down
File renamed without changes.

0 comments on commit 76f88a5

Please sign in to comment.