Skip to content

Commit 1b0a835

Browse files
authored
Make project.godot template version dynamic. (#807)
1 parent 8463543 commit 1b0a835

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

kt/plugins/godot-intellij-plugin/src/main/kotlin/godot/intellij/plugin/module/GodotModuleBuilder.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,21 @@ class GodotModuleBuilder : ModuleBuilder(), ModuleBuilderListener {
343343
outFile.writeText(
344344
outFile
345345
.readText()
346+
.replace(
347+
"GODOT_VERSION",
348+
GodotBuildProperties.godotVersion.run {
349+
// Ensure that the version string has at least one dot.
350+
val firstDotIndex = indexOf('.')
351+
if (firstDotIndex == -1) {
352+
throw IllegalArgumentException("Version must be in x.y or x.y.z format")
353+
}
354+
355+
// If there's no second dot, the version is already in x.y format.
356+
// Otherwise, cut off the version after the second dot to handle x.y.z format.
357+
val secondDotIndex = indexOf('.', firstDotIndex + 1)
358+
if (secondDotIndex == -1) this else substring(0, secondDotIndex)
359+
}
360+
)
346361
.replace("PROJECT_NAME", module.project.name)
347362
)
348363
}

kt/plugins/godot-intellij-plugin/src/main/resources/template/project.godot.intellij_template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ config_version=5
1111
[application]
1212

1313
config/name="PROJECT_NAME"
14-
config/features=PackedStringArray("4.2", "Forward Plus")
14+
config/features=PackedStringArray("GODOT_VERSION", "Forward Plus")
1515
config/icon="res://icon.svg"

0 commit comments

Comments
 (0)