Skip to content

Commit

Permalink
Reorganized to support betas and release candidates better, added ded…
Browse files Browse the repository at this point in the history
…icated support for godot 4 release candidates
  • Loading branch information
Frontrider committed Feb 11, 2023
1 parent 580566d commit f7fd35d
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 72 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "io.github.frontrider.godle"
version = "0.20.1"
version = "0.21.0"

repositories {
mavenCentral()
Expand Down
16 changes: 16 additions & 0 deletions src/main/kotlin/dsl/versioning/godot4.kt
Original file line number Diff line number Diff line change
@@ -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))
}
64 changes: 64 additions & 0 deletions src/main/kotlin/dsl/versioning/kotlin.kt
Original file line number Diff line number Diff line change
@@ -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))
}
92 changes: 21 additions & 71 deletions src/main/kotlin/dsl/versioning/versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()
)
}

0 comments on commit f7fd35d

Please sign in to comment.