Skip to content

Commit

Permalink
Merge pull request #2 from MartinHaeusler/feature/disable-script-gene…
Browse files Browse the repository at this point in the history
…ration

Sure, turn it off :)
  • Loading branch information
Frontrider authored Mar 18, 2024
2 parents af85e3c + 9dc7da9 commit b75c6b8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/dsl/GodleExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ abstract class GodleExtension @Inject constructor(objectFactory: ObjectFactory,
//set it to true, to create a blank godot project in the godot root.
var createBlankProject = true

/** When `true`, Godle will create several scripts to quickstart the Godot editor. */
var generateQuickstartScripts = true

val env = HashMap<String, String>()
fun env(key: String, value: String) {
env[key] = value
Expand Down
76 changes: 42 additions & 34 deletions src/main/kotlin/initializers/initBaseGodot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,10 @@ internal fun Project.initBaseGodot() {
file.writeText("")
}
}
//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.
File(project.rootDir, "editor.sh").apply {
if (!exists()) {
writeText(
"#!/bin/sh \n./gradlew godotEditor"
)
}
}
File(project.rootDir, "editor.bat").apply {
if (!exists()) {
writeText(
"gradlew.bat godotEditor"
)
}
}
File(project.rootDir, "game.sh").apply {
if (!exists()) {
writeText(
"#!/bin/sh \n./gradlew godotRunGame"
)
}
}
File(project.rootDir, "game.bat").apply {
if (!exists()) {
writeText("call gradlew.bat godotRunGame")
}

// only generate the quickstart scripts if the user wants us to
if(extension.generateQuickstartScripts){
generateQuickstartScripts(extension)
}

val storePath = "${extension.godotFolder}/"
Expand Down Expand Up @@ -166,4 +136,42 @@ 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.
File(project.rootDir, "editor.sh").apply {
if (!exists()) {
writeText(
"#!/bin/sh \n./gradlew godotEditor"
)
}
}
File(project.rootDir, "editor.bat").apply {
if (!exists()) {
writeText(
"gradlew.bat godotEditor"
)
}
}
File(project.rootDir, "game.sh").apply {
if (!exists()) {
writeText(
"#!/bin/sh \n./gradlew godotRunGame"
)
}
}
File(project.rootDir, "game.bat").apply {
if (!exists()) {
writeText("call gradlew.bat godotRunGame")
}
}
}

0 comments on commit b75c6b8

Please sign in to comment.