From aede030a7f50809051250373d2de55bad1574fa9 Mon Sep 17 00:00:00 2001 From: JFronny Date: Fri, 1 Mar 2024 21:25:11 +0100 Subject: [PATCH] chore: refactor build scripts and update java-gi --- build.gradle.kts | 12 ++--- buildSrc/build.gradle.kts | 7 +-- buildSrc/settings.gradle.kts | 9 +++- ...inceptum.application-standalone.gradle.kts | 8 +-- .../kotlin/inceptum.gson-compile.gradle.kts | 7 +-- .../src/main/kotlin/inceptum.java.gradle.kts | 5 +- common/build.gradle.kts | 14 ++--- gradle/libs.versions.toml | 52 +++++++++++++++++++ launcher-cli/build.gradle.kts | 4 +- launcher-dist/build.gradle.kts | 12 ++--- launcher-gtk/build.gradle.kts | 18 +++---- .../jfronny/inceptum/gtk/GtkEnvBackend.kt | 26 +++++----- .../io/gitlab/jfronny/inceptum/gtk/GtkMain.kt | 2 +- .../gtk/control/InstanceListEntryFactory.kt | 4 +- .../inceptum/gtk/control/settings/IRow.kt | 6 +-- .../inceptum/gtk/menu/BuiltRadioItem.kt | 2 +- .../inceptum/gtk/menu/BuiltToggleItem.kt | 2 +- .../jfronny/inceptum/gtk/menu/MenuBuilder.kt | 10 ++-- .../gtk/window/create/NewInstanceWindow.kt | 4 +- .../gtk/window/dialog/MicrosoftLoginDialog.kt | 2 +- .../window/settings/instance/GeneralTab.kt | 4 +- .../gtk/window/settings/instance/ModsTab.kt | 4 +- .../window/settings/launcher/AccountsTab.kt | 4 +- launcher-imgui/build.gradle.kts | 28 +++++----- launcher/build.gradle.kts | 12 ++--- launchwrapper/build.gradle.kts | 5 +- settings.gradle.kts | 2 + wrapper/build.gradle.kts | 4 +- 28 files changed, 156 insertions(+), 113 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/build.gradle.kts b/build.gradle.kts index 59ce42b..e14ae91 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,14 +10,14 @@ allprojects { } // common -val jfCommonsVersion by extra("1.5-SNAPSHOT") -val gsonCompileVersion by extra("1.4-SNAPSHOT") -val jbAnnotationsVersion by extra("24.0.1") +val jfCommonsVersion by extra(libs.versions.jf.commons.get()) +val gsonCompileVersion by extra(libs.versions.gson.compile.get()) +val jbAnnotationsVersion by extra(libs.versions.annotations.get()) // launcher-imgui -val lwjglVersion by extra("3.3.2") -val imguiVersion by extra("1.86.10") +val lwjglVersion by extra(libs.versions.lwjgl.get()) +val imguiVersion by extra(libs.versions.imgui.get()) // launcher-gtk -val javagiVersion by extra("0.8.1") +val javagiVersion by extra(libs.versions.javagi.get()) val flavorProp: String by extra(prop("flavor", "custom")) if (!setOf("custom", "maven", "fat", "windows", "linux", "macos").contains(flavorProp)) throw IllegalStateException("Unsupported flavor: $flavorProp") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index e239ad1..387ff78 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -8,7 +8,8 @@ repositories { } dependencies { - implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2") - implementation("de.undercouch:gradle-download-task:5.1.2") - implementation("io.gitlab.jfronny:convention:1.5-SNAPSHOT") + implementation(libs.plugin.shadow) + implementation(libs.plugin.download) + implementation(libs.plugin.jf.convention) + implementation(libs.plugin.jlink) } \ No newline at end of file diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index 5fceb4c..e2e344b 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -1 +1,8 @@ -rootProject.name="inceptum-conventions" \ No newline at end of file +rootProject.name="inceptum-conventions" +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/inceptum.application-standalone.gradle.kts b/buildSrc/src/main/kotlin/inceptum.application-standalone.gradle.kts index 1058f0c..266e20d 100644 --- a/buildSrc/src/main/kotlin/inceptum.application-standalone.gradle.kts +++ b/buildSrc/src/main/kotlin/inceptum.application-standalone.gradle.kts @@ -4,8 +4,8 @@ import java.io.FileOutputStream plugins { application id("inceptum.java") - id("com.github.johnrengelman.shadow") - id("de.undercouch.download") + com.github.johnrengelman.shadow + de.undercouch.download } abstract class FileOutput : DefaultTask() { @@ -18,14 +18,14 @@ val bootstrapArch = "i686" val downloadBootstrap by tasks.registering(Download::class) { src("https://maven.fabricmc.net/net/fabricmc/fabric-installer-native-bootstrap/windows-${bootstrapArch}/${bootstrapVersion}/windows-${bootstrapArch}-${bootstrapVersion}.exe") - dest(project.buildDir) + dest(project.layout.buildDirectory) } val nativeExe by tasks.registering(FileOutput::class) { dependsOn(downloadBootstrap) dependsOn(tasks.shadowJar) - output = file("$buildDir/libs/${project.name}-${project.version}.exe") + output = project.layout.buildDirectory.file("libs/${project.name}-${project.version}.exe").get().asFile outputs.upToDateWhen { false } doFirst { diff --git a/buildSrc/src/main/kotlin/inceptum.gson-compile.gradle.kts b/buildSrc/src/main/kotlin/inceptum.gson-compile.gradle.kts index d01ac1c..c64ba68 100644 --- a/buildSrc/src/main/kotlin/inceptum.gson-compile.gradle.kts +++ b/buildSrc/src/main/kotlin/inceptum.gson-compile.gradle.kts @@ -2,10 +2,11 @@ plugins { id("inceptum.library") } +val libs = extensions.getByType().named("libs") dependencies { - api("io.gitlab.jfronny.gson:gson-compile-core:${rootProject.extra["gsonCompileVersion"]}") - compileOnly("io.gitlab.jfronny.gson:gson-compile-annotations:${rootProject.extra["gsonCompileVersion"]}") - annotationProcessor("io.gitlab.jfronny.gson:gson-compile-processor:${rootProject.extra["gsonCompileVersion"]}") + api(libs.findLibrary("gson-compile-core").orElseThrow()) + compileOnly(libs.findLibrary("gson-compile-annotations").orElseThrow()) + annotationProcessor(libs.findLibrary("gson-compile-processor").orElseThrow()) } tasks.withType { diff --git a/buildSrc/src/main/kotlin/inceptum.java.gradle.kts b/buildSrc/src/main/kotlin/inceptum.java.gradle.kts index f166941..210c701 100644 --- a/buildSrc/src/main/kotlin/inceptum.java.gradle.kts +++ b/buildSrc/src/main/kotlin/inceptum.java.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("jf.java") + jf.java `maven-publish` } @@ -8,8 +8,9 @@ repositories { maven("https://maven.frohnmeyer-wds.de/artifacts") } +val libs = extensions.getByType().named("libs") dependencies { - compileOnly("org.jetbrains:annotations:23.0.0") + compileOnly(libs.findLibrary("annotations").orElseThrow()) } publishing { diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 43abd37..76657bc 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -2,19 +2,13 @@ import io.gitlab.jfronny.scripts.* import javax.lang.model.element.Modifier plugins { - id("inceptum.library") - id("jf.codegen") - id("inceptum.gson-compile") + inceptum.library + jf.codegen + inceptum.`gson-compile` } dependencies { - val jfCommonsVersion: String by rootProject.extra - - api("io.gitlab.jfronny:commons:$jfCommonsVersion") - api("io.gitlab.jfronny:commons-http-client:$jfCommonsVersion") - api("io.gitlab.jfronny:commons-io:$jfCommonsVersion") - api("io.gitlab.jfronny:commons-logging:$jfCommonsVersion") - api("io.gitlab.jfronny:commons-serialize-gson:$jfCommonsVersion") + api(libs.bundles.commons) } val javaVersion by extra(project.java.targetCompatibility) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..c7a21ed --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,52 @@ +[versions] +jf-commons = "1.5-SNAPSHOT" +gson-compile = "1.4-SNAPSHOT" +annotations = "24.0.1" +lwjgl = "3.3.2" +imgui = "1.86.10" +javagi = "0.9.0" +kotlin = "1.9.20" + +[libraries] +plugin-shadow = "gradle.plugin.com.github.johnrengelman:shadow:7.1.2" +plugin-download = "de.undercouch:gradle-download-task:5.1.2" +plugin-jf-convention = "io.gitlab.jfronny:convention:1.5-SNAPSHOT" +plugin-jlink = "org.beryx:badass-jlink-plugin:3.0.1" + +lwjgl-core = { module = "org.lwjgl:lwjgl", version.ref = "lwjgl" } +lwjgl-glfw = { module = "org.lwjgl:lwjgl-glfw", version.ref = "lwjgl" } +lwjgl-opengl = { module = "org.lwjgl:lwjgl-opengl", version.ref = "lwjgl" } +lwjgl-tinyfd = { module = "org.lwjgl:lwjgl-tinyfd", version.ref = "lwjgl" } +lwjgl-core-natives = { module = "org.lwjgl:lwjgl", version.ref = "lwjgl" } +lwjgl-glfw-natives = { module = "org.lwjgl:lwjgl-glfw", version.ref = "lwjgl" } +lwjgl-opengl-natives = { module = "org.lwjgl:lwjgl-opengl", version.ref = "lwjgl" } +lwjgl-tinyfd-natives = { module = "org.lwjgl:lwjgl-tinyfd", version.ref = "lwjgl" } + +imgui = { module = "io.github.spair:imgui-java-binding", version.ref = "imgui" } # https://github.com/SpaiR/imgui-java +imgui-lwjgl = { module = "io.github.spair:imgui-java-lwjgl3", version.ref = "imgui" } +imgui-natives-linux = { module = "io.github.spair:imgui-java-natives-linux", version.ref = "imgui" } +imgui-natives-windows = { module = "io.github.spair:imgui-java-natives-windows", version.ref = "imgui" } +imgui-natives-macos = { module = "io.github.spair:imgui-java-natives-macos", version.ref = "imgui" } + +javagi-glib = { module = "io.github.jwharm.javagi:glib", version.ref = "javagi" } +javagi-gtk = { module = "io.github.jwharm.javagi:gtk", version.ref = "javagi" } +javagi-adw = { module = "io.github.jwharm.javagi:adw", version.ref = "javagi" } + +commons = { module = "io.gitlab.jfronny:commons", version.ref = "jf-commons" } +commons-http-client = { module = "io.gitlab.jfronny:commons-http-client", version.ref = "jf-commons" } +commons-http-server = { module = "io.gitlab.jfronny:commons-http-server", version.ref = "jf-commons" } +commons-io = { module = "io.gitlab.jfronny:commons-io", version.ref = "jf-commons" } +commons-logging = { module = "io.gitlab.jfronny:commons-logging", version.ref = "jf-commons" } +commons-serialize-gson = { module = "io.gitlab.jfronny:commons-serialize-gson", version.ref = "jf-commons" } + +gson-compile-core = { module = "io.gitlab.jfronny.gson:gson-compile-core", version.ref = "gson-compile" } +gson-compile-annotations = { module = "io.gitlab.jfronny.gson:gson-compile-annotations", version.ref = "gson-compile" } +gson-compile-processor = { module = "io.gitlab.jfronny.gson:gson-compile-processor", version.ref = "gson-compile" } + +annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" } + +[bundles] +lwjgl = ["lwjgl-core", "lwjgl-glfw", "lwjgl-opengl", "lwjgl-tinyfd"] +lwjgl-natives = ["lwjgl-core-natives", "lwjgl-glfw-natives", "lwjgl-opengl-natives", "lwjgl-tinyfd-natives"] +javagi = ["javagi-glib", "javagi-gtk", "javagi-adw"] +commons = ["commons", "commons-http-client", "commons-io", "commons-logging", "commons-serialize-gson"] \ No newline at end of file diff --git a/launcher-cli/build.gradle.kts b/launcher-cli/build.gradle.kts index c099d75..6c5f2da 100644 --- a/launcher-cli/build.gradle.kts +++ b/launcher-cli/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("inceptum.application") + inceptum.application } application { @@ -7,5 +7,5 @@ application { } dependencies { - implementation(project(":launcher")) + implementation(projects.launcher) } diff --git a/launcher-dist/build.gradle.kts b/launcher-dist/build.gradle.kts index 6657d6c..235ac20 100644 --- a/launcher-dist/build.gradle.kts +++ b/launcher-dist/build.gradle.kts @@ -3,8 +3,8 @@ import java.nio.file.Files import java.nio.file.Path plugins { - id("inceptum.application-standalone") - id("org.beryx.jlink") version "2.26.0" + inceptum.`application-standalone` + org.beryx.jlink } application { @@ -14,9 +14,9 @@ application { } dependencies { - implementation(project(":launcher")) - implementation(project(":launcher-cli")) - implementation(project(":launcher-imgui")) + implementation(projects.launcher) + implementation(projects.launcherCli) + implementation(projects.launcherImgui) } tasks.shadowJar { @@ -121,7 +121,7 @@ if (crosscompile) { tasks.jpackage { doLast { val src = Path.of("/root/jpackage-out") - val trg = buildDir.resolve("jpackage").toPath() + val trg = layout.buildDirectory.dir("jpackage").get().asFile.toPath() Files.createDirectories(trg) Files.list(src).use { it.filter { Files.isRegularFile(it) }.forEach { diff --git a/launcher-gtk/build.gradle.kts b/launcher-gtk/build.gradle.kts index 5826f2f..4932a0a 100644 --- a/launcher-gtk/build.gradle.kts +++ b/launcher-gtk/build.gradle.kts @@ -1,10 +1,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - id("inceptum.application") - id("com.github.johnrengelman.shadow") - kotlin("jvm") version "1.9.20" - kotlin("plugin.sam.with.receiver") version "1.9.20" + inceptum.application + com.github.johnrengelman.shadow + kotlin("jvm") version libs.versions.kotlin + kotlin("plugin.sam.with.receiver") version libs.versions.kotlin } application { @@ -15,17 +15,11 @@ samWithReceiver { annotation("io.gitlab.jfronny.commons.SamWithReceiver") } -repositories { - mavenLocal() -} - dependencies { val javagiVersion: String by rootProject.extra - //implementation("io.github.jwharm.javagi:glib:$javagiVersion") - //implementation("io.github.jwharm.javagi:gtk:$javagiVersion") - implementation("io.github.jwharm.javagi:adw:$javagiVersion") - implementation(project(":launcher")) + implementation(libs.bundles.javagi) + implementation(projects.launcher) } tasks.compileJava { diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/GtkEnvBackend.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/GtkEnvBackend.kt index 84185a8..3571c50 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/GtkEnvBackend.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/GtkEnvBackend.kt @@ -73,19 +73,19 @@ object GtkEnvBackend : EnvBackend { cancel: Runnable? ) { val dialog = AlertDialog.builder() - .message(title) - .detail(markup) - .modal(true) + .setMessage(title) + .setDetail(markup) + .setModal(true) when { - cancel == null -> dialog.buttons(arrayOf(I18n["ok"])) - .defaultButton(0) - .cancelButton(-1) - ok == null -> dialog.buttons(arrayOf("Cancel")) - .defaultButton(-1) - .cancelButton(0) - else -> dialog.buttons(arrayOf("OK", "Cancel")) - .defaultButton(0) - .cancelButton(1) + cancel == null -> dialog.setButtons(arrayOf(I18n["ok"])) + .setDefaultButton(0) + .setCancelButton(-1) + ok == null -> dialog.setButtons(arrayOf("Cancel")) + .setDefaultButton(-1) + .setCancelButton(0) + else -> dialog.setButtons(arrayOf("OK", "Cancel")) + .setDefaultButton(0) + .setCancelButton(1) } dialog.build().apply { choose(parent, Cancellable()) { _, res, _ -> @@ -98,7 +98,7 @@ object GtkEnvBackend : EnvBackend { } } - private fun processResponses(dialog: Dialog, ok: Runnable?, cancel: Runnable?): Dialog.Response = Dialog.Response { responseId: Int -> + private fun processResponses(dialog: Dialog, ok: Runnable?, cancel: Runnable?): Dialog.ResponseCallback = Dialog.ResponseCallback { responseId: Int -> when (ResponseType.of(responseId)) { ResponseType.OK -> { dialog.close() diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/GtkMain.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/GtkMain.kt index 2c7aa53..a1fa9dd 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/GtkMain.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/GtkMain.kt @@ -47,7 +47,7 @@ object GtkMain { fun setupApplication(args: Array, onActivate: Application.() -> Unit): Int { val app = Application(ID, ApplicationFlags.FLAGS_NONE) app.onActivate { - GLib.idleAdd { + GLib.idleAdd(GLib.PRIORITY_DEFAULT_IDLE) { runScheduledTasks() true } diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/InstanceListEntryFactory.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/InstanceListEntryFactory.kt index 612d7b1..bec2ac8 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/InstanceListEntryFactory.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/InstanceListEntryFactory.kt @@ -29,7 +29,7 @@ class InstanceListEntryFactory( val thumbnail = InstanceThumbnail() thumbnail.name = "inceptum-thumbnail" - val launch = Button.newFromIconName("media-playback-start-symbolic") + val launch = Button.fromIconName("media-playback-start-symbolic") launch.addCssClass("flat") launch.name = "inceptum-launch" launch.tooltipText = I18n["instance.launch"] @@ -37,7 +37,7 @@ class InstanceListEntryFactory( val menu = MenuButton() menu.addCssClass("flat") menu.iconName = "view-more-symbolic" - menu.setPopover(PopoverMenu.newFromModel(Menu())) + menu.setPopover(PopoverMenu.fromModel(Menu())) val row = ActionRow() row.margin = 8 diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/IRow.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/IRow.kt index 549ffe7..d96d56e 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/IRow.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/settings/IRow.kt @@ -36,8 +36,8 @@ class IRow( append(head) } - fun setButton(text: @PropertyKey(resourceBundle = I18n.BUNDLE) String, action: Button.Clicked?): Button = - Button.newWithLabel(I18n[text]).apply { + fun setButton(text: @PropertyKey(resourceBundle = I18n.BUNDLE) String, action: Button.ClickedCallback?): Button = + Button.withLabel(I18n[text]).apply { packSmallEnd() onClicked(action) } @@ -59,7 +59,7 @@ class IRow( } fun setSpinButton(value: Double, min: Double, max: Double, step: Double, changed: DoubleConsumer): SpinButton = - SpinButton.newWithRange(min, max, step).apply { + SpinButton.withRange(min, max, step).apply { packSmallEnd() this.value = value onValueChanged { changed.accept(this.value) } diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/BuiltRadioItem.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/BuiltRadioItem.kt index 63a10eb..6f8fbcd 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/BuiltRadioItem.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/BuiltRadioItem.kt @@ -7,6 +7,6 @@ class BuiltRadioItem(action: SimpleAction, private val options: List) : Bu var selected: T get() = options[action.state!!.int32] set(selected) { - action.state = Variant.newInt32(options.indexOf(selected)) + action.state = Variant.int32(options.indexOf(selected)) } } diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/BuiltToggleItem.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/BuiltToggleItem.kt index b52c931..508cbf4 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/BuiltToggleItem.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/BuiltToggleItem.kt @@ -8,7 +8,7 @@ class BuiltToggleItem(action: SimpleAction, menuItem: MenuItem?) : BuiltMenuItem var state: Boolean get() = action.state!!.boolean set(state) { - action.state = Variant.newBoolean(state) + action.state = Variant.boolean_(state) } fun toggle(): Boolean { diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/MenuBuilder.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/MenuBuilder.kt index 3402f00..babbaf9 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/MenuBuilder.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/menu/MenuBuilder.kt @@ -62,11 +62,11 @@ class MenuBuilder private constructor(map: ActionMap, menu: Menu, prefix: String fun toggle(name: String, initial: Boolean, onToggle: Consumer): BuiltToggleItem { var name = name name = prefix + name - val action = SimpleAction.newStateful(name, null, Variant.newBoolean(initial)) + val action = SimpleAction.stateful(name, null, Variant.boolean_(initial)) addAction(name, action) action.onActivate { _ -> val state = !action.getState()!!.boolean - action.state = Variant.newBoolean(state) + action.state = Variant.boolean_(state) onToggle.accept(state) } val menuItem = MenuItem(I18n["menu.$name"], groupName + name) @@ -87,7 +87,7 @@ class MenuBuilder private constructor(map: ActionMap, menu: Menu, prefix: String ): BuiltRadioItem { var name = name name = prefix + name - val action = SimpleAction.newStateful(name, VariantTypes.INT32, Variant.newInt32(options.indexOf(initial))) + val action = SimpleAction.stateful(name, VariantTypes.INT32, Variant.int32(options.indexOf(initial))) addAction(name, action) action.onActivate { variant: Variant? -> action.state = variant @@ -135,7 +135,7 @@ class MenuBuilder private constructor(map: ActionMap, menu: Menu, prefix: String } fun asPopover(): PopoverMenu { - return PopoverMenu.newFromModel(menu) + return PopoverMenu.fromModel(menu) } companion object { @@ -155,7 +155,7 @@ class MenuBuilder private constructor(map: ActionMap, menu: Menu, prefix: String fun create(target: MenuButton, groupName: String): MenuBuilder { val menu = Menu() - val pm = PopoverMenu.newFromModel(menu) + val pm = PopoverMenu.fromModel(menu) target.setPopover(pm) return MenuBuilder(pm, groupName) } diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/create/NewInstanceWindow.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/create/NewInstanceWindow.kt index ab06809..35a1906 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/create/NewInstanceWindow.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/create/NewInstanceWindow.kt @@ -58,8 +58,8 @@ class NewInstanceWindow(app: Application) : KAssistant(app) { var versions = arrayOf() var def = 0 - val none = CheckButton.newWithLabel("None") - val fabric = CheckButton.newWithLabel("Fabric") + val none = CheckButton.withLabel("None") + val fabric = CheckButton.withLabel("Fabric") none.onToggled { useFabric = false } none.onToggled { useFabric = true } fabric.setGroup(none) diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/dialog/MicrosoftLoginDialog.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/dialog/MicrosoftLoginDialog.kt index 9698324..3d151db 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/dialog/MicrosoftLoginDialog.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/dialog/MicrosoftLoginDialog.kt @@ -50,7 +50,7 @@ class MicrosoftLoginDialog( else -> Log.error("Unexpected response type: $responseId") } } - val btn = Button.newWithLabel(I18n["auth.open-browser"]) + val btn = Button.withLabel(I18n["auth.open-browser"]) (messageArea as Box).append(btn) btn.onClicked { try { diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/GeneralTab.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/GeneralTab.kt index 97b1a20..48d131b 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/GeneralTab.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/GeneralTab.kt @@ -31,7 +31,7 @@ class GeneralTab(window: InstanceSettingsWindow) : SectionedSettingsTab apply.sensitive = s != instance.name } entry.placeholderText = I18n["instance.settings.general.name.placeholder"] apply.valign = Align.CENTER @@ -127,7 +127,7 @@ class GeneralTab(window: InstanceSettingsWindow) : SectionedSettingsTab(window) { private fun Section.build() { generateRows() - val row = Button.newFromIconName("list-add-symbolic") + val row = Button.fromIconName("list-add-symbolic") row(row) row.onClicked { MicrosoftLoginDialog(window) { @@ -46,7 +46,7 @@ class AccountsTab(window: Window?) : SectionedSettingsTab(window) { subtitle.halign = Align.START head.append(subtitle) row.append(head) - val remove = Button.newFromIconName("window-close-symbolic") + val remove = Button.fromIconName("window-close-symbolic") remove.valign = Align.CENTER remove.halign = Align.END remove.onClicked { diff --git a/launcher-imgui/build.gradle.kts b/launcher-imgui/build.gradle.kts index 8fe835c..d2025eb 100644 --- a/launcher-imgui/build.gradle.kts +++ b/launcher-imgui/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("inceptum.application") + inceptum.application } application { @@ -8,23 +8,21 @@ application { dependencies { val flavor: String by rootProject.extra - val lwjglVersion: String by rootProject.extra - val imguiVersion: String by rootProject.extra - fun native(name: String) { - if (flavor == "windows" || flavor == "fat") implementation(name.replace("@platform", "windows")) - if (flavor == "linux" || flavor == "fat") implementation(name.replace("@platform", "linux")) - if (flavor == "macos" || flavor == "fat") implementation(name.replace("@platform", "macos")) + implementation(projects.launcher) + + fun forEachPlatform(action: (String) -> Unit) { + (if (flavor == "fat") listOf("windows", "linux", "macos") else listOf(flavor)).forEach(action) } - implementation(project(":launcher")) - - arrayOf("", "-opengl", "-glfw", "-tinyfd").forEach { - implementation("org.lwjgl:lwjgl$it:$lwjglVersion") - native("org.lwjgl:lwjgl$it:$lwjglVersion:natives-@platform") + implementation(libs.bundles.lwjgl) + libs.bundles.lwjgl.natives.get().forEach { + forEachPlatform { suffix -> implementation(variantOf(provider { it }) { classifier("natives-$suffix") }) } } - implementation("io.github.spair:imgui-java-binding:$imguiVersion") // https://github.com/SpaiR/imgui-java - implementation("io.github.spair:imgui-java-lwjgl3:$imguiVersion") - native("io.github.spair:imgui-java-natives-@platform:$imguiVersion") + implementation(libs.imgui) + implementation(libs.imgui.lwjgl) + if (flavor == "windows" || flavor == "fat") implementation(libs.imgui.natives.windows) + if (flavor == "linux" || flavor == "fat") implementation(libs.imgui.natives.linux) + if (flavor == "macos" || flavor == "fat") implementation(libs.imgui.natives.macos) } diff --git a/launcher/build.gradle.kts b/launcher/build.gradle.kts index c36c9e0..9f51cc6 100644 --- a/launcher/build.gradle.kts +++ b/launcher/build.gradle.kts @@ -1,13 +1,9 @@ plugins { - id("inceptum.library") - id("inceptum.gson-compile") + inceptum.library + inceptum.`gson-compile` } dependencies { - val jfCommonsVersion: String by rootProject.extra - val jbAnnotationsVersion: String by rootProject.extra - - api(project(":common")) - api("io.gitlab.jfronny:commons-http-server:$jfCommonsVersion") // required for launcher-gtk for some reason - compileOnly("org.jetbrains:annotations:$jbAnnotationsVersion") + api(projects.common) + api(libs.commons.http.server) // required for launcher-gtk for some reason } diff --git a/launchwrapper/build.gradle.kts b/launchwrapper/build.gradle.kts index 98c9cfc..54f5d59 100644 --- a/launchwrapper/build.gradle.kts +++ b/launchwrapper/build.gradle.kts @@ -1,11 +1,8 @@ plugins { - id("inceptum.library") + inceptum.library } java { targetCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8 } - -dependencies { -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 37f7886..3973b81 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,3 +8,5 @@ include("launcher-imgui") include("launcher-dist") include("launchwrapper") include("launcher-gtk") + +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") \ No newline at end of file diff --git a/wrapper/build.gradle.kts b/wrapper/build.gradle.kts index 171c923..04f1602 100644 --- a/wrapper/build.gradle.kts +++ b/wrapper/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("inceptum.application-standalone") + inceptum.`application-standalone` } application { @@ -7,7 +7,7 @@ application { } dependencies { - implementation(project(":common")) + implementation(projects.common) } tasks.runShadow.get().workingDir = rootProject.projectDir \ No newline at end of file