diff --git a/build.gradle.kts b/build.gradle.kts index 797e311..0ddf78e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "io.github.frontrider.godle" -version = "0.20.1" +version = "0.21.0" repositories { mavenCentral() diff --git a/src/main/kotlin/dsl/versioning/godot4.kt b/src/main/kotlin/dsl/versioning/godot4.kt new file mode 100644 index 0000000..324f074 --- /dev/null +++ b/src/main/kotlin/dsl/versioning/godot4.kt @@ -0,0 +1,16 @@ +@file:Suppress("unused") + +package io.github.frontrider.godle.dsl.versioning + +import io.github.frontrider.godle.dsl.GodleExtension + + +infix fun GodleExtension.asGodot4Beta(version: String){ + this.version.set(godotBeta("4.0",version)) +} + + + +infix fun GodleExtension.asGodot4releaseCandidate(version: String){ + this.version.set(godotReleaseCandidate("4.0",version)) +} diff --git a/src/main/kotlin/dsl/versioning/kotlin.kt b/src/main/kotlin/dsl/versioning/kotlin.kt new file mode 100644 index 0000000..40c3ffc --- /dev/null +++ b/src/main/kotlin/dsl/versioning/kotlin.kt @@ -0,0 +1,64 @@ +@file:Suppress("unused", "UnusedReceiverParameter") + +package io.github.frontrider.godle.dsl.versioning + +import io.github.frontrider.godle.dsl.GodleExtension + + +var jvmPath:String? = null +//kotlin/jvm support +fun GodleExtension.`kotlin-jvm`(version: String, detectJVM: Boolean = true): GodotVersion { + return GodotVersion( + version = version, + cacheName = "v%version%-%bit%-kotlin", + linuxDownloadURL = "https://github.com/utopia-rise/godot-kotlin-jvm/releases/download/%version%/godot-kotlin-jvm_editor_x11_.zip", + windowsDownloadURL = "https://github.com/utopia-rise/godot-kotlin-jvm/releases/download/%version%/godot-kotlin-jvm_editor_windows_.zip", + macDownloadURL = "https://github.com/utopia-rise/godot-kotlin-jvm/releases/download/%version%/godot-kotlin-jvm_editor_osx_.zip", + linuxBinary = "godot.x11.opt.tools.%bit%", + windowsBinary = "godot.windows.opt.tools.%bit%.exe", + macBinary = "godot.osx.opt.tools.%bit%", + execTask = { exec -> + //the exec task detects the current JVM + if (detectJVM) { + if(jvmPath != null){ + exec.environment("JAVA_HOME", jvmPath!!) + return@GodotVersion + } + println("attempting to detect jvm!") + + //attempt to determine the current JVM's path and use it. + val command = ProcessHandle.current() + .info() + .command() + + if (command.isPresent) { + val javaHome = command.get().removeSuffix("/bin/java") + println("jvm found at $javaHome") + //determine from the process itself, this is the most secure variant + exec.environment("JAVA_HOME", javaHome) + jvmPath= javaHome + } else { + //determine from an environment variable, will most likely be set, but it may not be the correct one. + val javaHome = System.getProperty("java.home") + if (javaHome != null) { + println("jvm found at $javaHome") + exec.environment("JAVA_HOME", javaHome) + jvmPath= javaHome + } + } + } + } + ) +} + +/** + * This variant exists for groovy. + * */ +fun GodleExtension.kotlinJvm(version: String, detectJVM: Boolean = true): GodotVersion { + return `kotlin-jvm`(version, detectJVM) +} + + +infix fun GodleExtension.`asKotlin-jvm`(version: String) { + this.version.set(`kotlin-jvm`(version)) +} \ No newline at end of file diff --git a/src/main/kotlin/dsl/versioning/versions.kt b/src/main/kotlin/dsl/versioning/versions.kt index 6029417..33e1564 100644 --- a/src/main/kotlin/dsl/versioning/versions.kt +++ b/src/main/kotlin/dsl/versioning/versions.kt @@ -23,25 +23,6 @@ infix fun GodleExtension.asGodot(version: String) { this.version.set(godot(version)) } -infix fun GodleExtension.godot4Beta(version: String): GodotVersion { - return GodotVersion( - version = version, - cacheName = "godot-4.0-beta-%version%-%bit%", - linuxDownloadURL = "https://downloads.tuxfamily.org/godotengine/4.0/beta%version%/Godot_v4.0-beta%version%_linux.x86_%bit%.zip", - windowsDownloadURL = "https://downloads.tuxfamily.org/godotengine/4.0/beta%version%/Godot_v4.0-beta%version%winx%bit%.exe.zip", - macDownloadURL = "https://downloads.tuxfamily.org/godotengine/4.0/beta%version%/Godot_v4.0-beta%version%_macos.universal.zip", - linuxBinary = "Godot_v4.0-beta%version%_linux.x86_%bit%", - windowsBinary = "Godot_v4.0-beta%version%win%bit%.exe", - macBinary = "Godot.app/Contents/MacOS/Godot", - majorVersion = versionAsGodot4() - ) -} - -infix fun GodleExtension.asGodot4Beta(version: String){ - this.version.set(godot4Beta(version)) -} - - //c# support fun GodleExtension.mono(version: String): GodotVersion { return GodotVersion( @@ -79,61 +60,30 @@ fun GodleExtension.asLocal(binaryPath: String,majorVersion: MajorVersion){ infix fun GodleExtension.asMono(version: String) { this.version.set(mono(version)) } - -var jvmPath:String? = null -//kotlin/jvm support -fun GodleExtension.`kotlin-jvm`(version: String, detectJVM: Boolean = true): GodotVersion { +fun GodleExtension.godotBeta(majorVersion:String,version: String): GodotVersion { return GodotVersion( version = version, - cacheName = "v%version%-%bit%-kotlin", - linuxDownloadURL = "https://github.com/utopia-rise/godot-kotlin-jvm/releases/download/%version%/godot-kotlin-jvm_editor_x11_.zip", - windowsDownloadURL = "https://github.com/utopia-rise/godot-kotlin-jvm/releases/download/%version%/godot-kotlin-jvm_editor_windows_.zip", - macDownloadURL = "https://github.com/utopia-rise/godot-kotlin-jvm/releases/download/%version%/godot-kotlin-jvm_editor_osx_.zip", - linuxBinary = "godot.x11.opt.tools.%bit%", - windowsBinary = "godot.windows.opt.tools.%bit%.exe", - macBinary = "godot.osx.opt.tools.%bit%", - execTask = { exec -> - //the exec task detects the current JVM - if (detectJVM) { - if(jvmPath != null){ - exec.environment("JAVA_HOME", jvmPath!!) - return@GodotVersion - } - println("attempting to detect jvm!") - - //attempt to determine the current JVM's path and use it. - val command = ProcessHandle.current() - .info() - .command() - - if (command.isPresent) { - val javaHome = command.get().removeSuffix("/bin/java") - println("jvm found at $javaHome") - //determine from the process itself, this is the most secure variant - exec.environment("JAVA_HOME", javaHome) - jvmPath= javaHome - } else { - //determine from an environment variable, will most likely be set, but it may not be the correct one. - val javaHome = System.getProperty("java.home") - if (javaHome != null) { - println("jvm found at $javaHome") - exec.environment("JAVA_HOME", javaHome) - jvmPath= javaHome - } - } - } - } + cacheName = "godot-$majorVersion-beta-%version%-%bit%", + linuxDownloadURL = "https://downloads.tuxfamily.org/godotengine/$majorVersion/beta%version%/Godot_v$majorVersion-beta%version%_linux.x86_%bit%.zip", + windowsDownloadURL = "https://downloads.tuxfamily.org/godotengine/$majorVersion/beta%version%/Godot_v$majorVersion-beta%version%winx%bit%.exe.zip", + macDownloadURL = "https://downloads.tuxfamily.org/godotengine/$majorVersion/beta%version%/Godot_v$majorVersion-beta%version%_macos.universal.zip", + linuxBinary = "Godot_v$majorVersion-beta%version%_linux.x86_%bit%", + windowsBinary = "Godot_v$majorVersion-beta%version%win%bit%.exe", + macBinary = "Godot.app/Contents/MacOS/Godot", + majorVersion = versionAsGodot4() ) } -/** - * This variant exists for groovy. - * */ -fun GodleExtension.kotlinJvm(version: String, detectJVM: Boolean = true): GodotVersion { - return `kotlin-jvm`(version, detectJVM) -} - - -infix fun GodleExtension.`asKotlin-jvm`(version: String) { - this.version.set(`kotlin-jvm`(version)) +fun GodleExtension.godotReleaseCandidate(majorVersion:String,version: String): GodotVersion { + return GodotVersion( + version = version, + cacheName = "godot-$majorVersion-rc-%version%-%bit%", + linuxDownloadURL = "https://downloads.tuxfamily.org/godotengine/$majorVersion/rc%version%/Godot_v$majorVersion-rc%version%_linux.x86_%bit%.zip", + windowsDownloadURL = "https://downloads.tuxfamily.org/godotengine/$majorVersion/rc%version%/Godot_v$majorVersion-rc%version%winx%bit%.exe.zip", + macDownloadURL = "https://downloads.tuxfamily.org/godotengine/$majorVersion/rc%version%/Godot_v$majorVersion-rc%version%_macos.universal.zip", + linuxBinary = "Godot_v$majorVersion-rc%version%_linux.x86_%bit%", + windowsBinary = "Godot_v$majorVersion-rc%version%win%bit%.exe", + macBinary = "Godot.app/Contents/MacOS/Godot", + majorVersion = versionAsGodot4() + ) } \ No newline at end of file