diff --git a/src/integrationTest/kotlin/TestRunner.kt b/src/integrationTest/kotlin/TestRunner.kt index 8656e5a..64c2d81 100644 --- a/src/integrationTest/kotlin/TestRunner.kt +++ b/src/integrationTest/kotlin/TestRunner.kt @@ -17,4 +17,49 @@ class TestRunner { output.assertContains("Godot information:","Header not printed") output.assertContains("Current version: 3.5","Godot version not printed") } + + @ParameterizedTest + @ArgumentsSource(ScriptTypeArgumentProvider::class) + fun `can disable shell script generation`(postfix: String, @TempDir tempDir: File) { + "respectShellScriptGeneration".createBuildFile(postfix, tempDir) + //run the tasks we want + doRun(tempDir, listOf("tasks", "buildEnvironment"), "--stacktrace") + + // The build file specifies NOT to generate the shell scripts. + // Check if the setting was respected and the files haven't been generated. + val allFiles = tempDir.listFiles() ?: emptyArray() + allFiles.assertFileNotPresent("editor.sh") + allFiles.assertFileNotPresent("editor.bat") + allFiles.assertFileNotPresent("game.sh") + allFiles.assertFileNotPresent("game.bat") + } + + @ParameterizedTest + @ArgumentsSource(ScriptTypeArgumentProvider::class) + fun `shell scripts are generated by default`(postfix: String, @TempDir tempDir: File) { + + "noconfig".createBuildFile(postfix, tempDir) + //run the tasks we want + doRun(tempDir, listOf("tasks", "buildEnvironment"), "--stacktrace") + // The build file specifies NOT to generate the shell scripts. + // Check if the setting was respected and the files haven't been generated. + val allFiles = tempDir.listFiles() ?: emptyArray() + allFiles.assertFileIsPresent("editor.sh") + allFiles.assertFileIsPresent("editor.bat") + allFiles.assertFileIsPresent("game.sh") + allFiles.assertFileIsPresent("game.bat") + } + + private fun Array.assertFileIsPresent(fileName: String) { + assert(any { it.name == fileName }) { + "The file '${fileName}' does not exist even though it should exist." + } + } + + private fun Array.assertFileNotPresent(fileName: String) { + assert(none { it.name == fileName }) { + "The file '${fileName}' exists even though it shouldn't exist." + } + } + } \ No newline at end of file diff --git a/src/integrationTest/resources/respectShellScriptGeneration/build.gradle b/src/integrationTest/resources/respectShellScriptGeneration/build.gradle new file mode 100644 index 0000000..ad4fe71 --- /dev/null +++ b/src/integrationTest/resources/respectShellScriptGeneration/build.gradle @@ -0,0 +1,7 @@ +plugins { + id 'io.github.frontrider.godle' +} + +godle { + generateQuickstartScripts = false +} \ No newline at end of file diff --git a/src/integrationTest/resources/respectShellScriptGeneration/build.gradle.kts b/src/integrationTest/resources/respectShellScriptGeneration/build.gradle.kts new file mode 100644 index 0000000..33c4252 --- /dev/null +++ b/src/integrationTest/resources/respectShellScriptGeneration/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + id("io.github.frontrider.godle") +} + +godle { + generateQuickstartScripts = false +} \ No newline at end of file diff --git a/src/main/kotlin/initializers/initBaseGodot.kt b/src/main/kotlin/initializers/initBaseGodot.kt index b14c038..3a5ffcb 100644 --- a/src/main/kotlin/initializers/initBaseGodot.kt +++ b/src/main/kotlin/initializers/initBaseGodot.kt @@ -33,32 +33,10 @@ internal fun Project.initBaseGodot() { } } //create runner scripts - // Not in a task, to make it less cumbersome. - File(project.projectDir, "editor.sh").apply { - if (!exists()) { - writeText( - "#!/bin/sh \n./gradlew godotEditor" - ) - } - } - File(project.projectDir, "editor.bat").apply { - if (!exists()) { - writeText( - "gradlew.bat godotEditor" - ) - } - } - File(project.projectDir, "game.sh").apply { - if (!exists()) { - writeText( - "#!/bin/sh \n./gradlew godotRunGame" - ) - } - } - File(project.projectDir, "game.bat").apply { - if (!exists()) { - writeText("call gradlew.bat godotRunGame") - } + if(extension.generateQuickstartScripts){ + // create runner scripts + // Not in a task, to make it less cumbersome. + this.generateQuickstartScripts() } val storePath = "${extension.godotFolder}/" @@ -166,16 +144,7 @@ internal fun Project.initBaseGodot() { } } -private fun Project.generateQuickstartScripts(extension: GodleExtension) { - //ignore the gradle wrapper's folder. - if (File(project.rootDir, "gradle/").exists()) { - val file = File(project.rootDir, "gradle/.gdignore") - if (!file.exists()) { - file.writeText("") - } - } - //create runner scripts - // Not in a task, to make it less cumbersome. +private fun Project.generateQuickstartScripts() { File(project.rootDir, "editor.sh").apply { if (!exists()) { writeText(