Move initscripts into src/resources/init-scripts

This commit is contained in:
Daz DeBoer 2022-06-11 09:18:48 -06:00
parent a8d44c9749
commit 3d091fa7a8
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D
4 changed files with 4 additions and 4 deletions

View file

@ -175,15 +175,15 @@ export class GradleStateCache {
private initializeGradleUserHome(gradleUserHome: string, initScriptsDir: string): void { private initializeGradleUserHome(gradleUserHome: string, initScriptsDir: string): void {
const initScriptFilenames = ['build-result-capture.init.gradle', 'build-result-capture-service.plugin.groovy'] const initScriptFilenames = ['build-result-capture.init.gradle', 'build-result-capture-service.plugin.groovy']
for (const initScriptFilename of initScriptFilenames) { for (const initScriptFilename of initScriptFilenames) {
const initScriptContent = this.readResourceAsString(initScriptFilename) const initScriptContent = this.readInitScriptAsString(initScriptFilename)
const initScriptPath = path.resolve(initScriptsDir, initScriptFilename) const initScriptPath = path.resolve(initScriptsDir, initScriptFilename)
fs.writeFileSync(initScriptPath, initScriptContent) fs.writeFileSync(initScriptPath, initScriptContent)
} }
} }
private readResourceAsString(resource: string): string { private readInitScriptAsString(resource: string): string {
// Resolving relative to __dirname will allow node to find the resource at runtime // Resolving relative to __dirname will allow node to find the resource at runtime
const absolutePath = path.resolve(__dirname, '..', '..', 'src', 'resources', resource) const absolutePath = path.resolve(__dirname, '..', '..', 'src', 'resources', 'init-scripts', resource)
return fs.readFileSync(absolutePath, 'utf8') return fs.readFileSync(absolutePath, 'utf8')
} }

View file

@ -100,7 +100,7 @@ class BaseInitScriptTest extends Specification {
settingsFile = new File(testProjectDir, 'settings.gradle') settingsFile = new File(testProjectDir, 'settings.gradle')
buildFile = new File(testProjectDir, 'build.gradle') buildFile = new File(testProjectDir, 'build.gradle')
File srcInitScriptsDir = new File("../../src/resources") File srcInitScriptsDir = new File("../../src/resources/init-scripts")
File targetInitScriptsDir = new File(testProjectDir, "initScripts") File targetInitScriptsDir = new File(testProjectDir, "initScripts")
targetInitScriptsDir.mkdirs() targetInitScriptsDir.mkdirs()