From 2d7f46e9dbda1dd46a0e38a6aba9904fce91ec7e Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Tue, 14 Jan 2025 02:42:12 +0100 Subject: [PATCH] Migrate to convention build scripts, update to Kotlin 2.1 --- ansi/build.gradle.kts | 8 +- base/build.gradle.kts | 8 +- build.gradle.kts | 258 +----------------- buildSrc/build.gradle.kts | 55 ++++ .../main/kotlin/engine.application.gradle.kts | 92 +++++++ .../src/main/kotlin/engine.generic.gradle.kts | 214 +++++++++++++++ .../engine.generic.properties.gradle.kts | 77 ++++++ gradle.properties | 10 +- settings.gradle.kts | 15 +- testapp/build.gradle.kts | 95 +------ testing/build.gradle.kts | 8 +- 11 files changed, 475 insertions(+), 365 deletions(-) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/engine.application.gradle.kts create mode 100644 buildSrc/src/main/kotlin/engine.generic.gradle.kts create mode 100644 buildSrc/src/main/kotlin/engine.generic.properties.gradle.kts diff --git a/ansi/build.gradle.kts b/ansi/build.gradle.kts index 0863746..d6b0fb0 100644 --- a/ansi/build.gradle.kts +++ b/ansi/build.gradle.kts @@ -1,6 +1,6 @@ /* * STAROPENSOURCE ENGINE SOURCE FILE - * Copyright (c) 2024 The StarOpenSource Engine Authors + * Copyright (c) 2025 The StarOpenSource Engine Authors * Licensed under the GNU General Public License v3. * * This program is free software: you can redistribute it and/or modify @@ -17,6 +17,12 @@ * along with this program. If not, see . */ +// Plugins +plugins { + id("engine.generic") + id("engine.generic.properties") +} + // Dependencies dependencies { // sos!engine diff --git a/base/build.gradle.kts b/base/build.gradle.kts index 0400252..c6cb3a6 100644 --- a/base/build.gradle.kts +++ b/base/build.gradle.kts @@ -1,6 +1,6 @@ /* * STAROPENSOURCE ENGINE SOURCE FILE - * Copyright (c) 2024 The StarOpenSource Engine Authors + * Copyright (c) 2025 The StarOpenSource Engine Authors * Licensed under the GNU General Public License v3. * * This program is free software: you can redistribute it and/or modify @@ -17,6 +17,12 @@ * along with this program. If not, see . */ +// Plugins +plugins { + id("engine.generic") + id("engine.generic.properties") +} + // Dependencies dependencies { // OSHI diff --git a/build.gradle.kts b/build.gradle.kts index f3ae658..f539236 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ /* * STAROPENSOURCE ENGINE SOURCE FILE - * Copyright (c) 2024 The StarOpenSource Engine Authors + * Copyright (c) 2025 The StarOpenSource Engine Authors * Licensed under the GNU General Public License v3. * * This program is free software: you can redistribute it and/or modify @@ -17,261 +17,7 @@ * along with this program. If not, see . */ -import ca.solostudios.nyx.util.reposiliteMaven -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.gradle.DokkaTask -import java.net.URI - -/* - * STAROPENSOURCE ENGINE SOURCE FILE - * Copyright (c) 2024 The StarOpenSource Engine Authors - * Licensed under the GNU Affero General Public License v3 - * with an exception allowing classpath linking. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - // Plugins plugins { - id("java-library") - id("maven-publish") - - // Kotlin support - id("org.jetbrains.kotlin.jvm") version("2.0.0") - - // Dokka - id("org.jetbrains.dokka") version("1.9.20") - - // Git properties - id("com.gorylenko.gradle-git-properties") version("2.4.2") - - // Nyx - // Smol props to the creator of this plugin! - // solonovamax helped me (JeremyStarTM) improve - // this build script. - id("ca.solo-studios.nyx") version("0.2.3") -} - -allprojects { - // Plugins - apply(plugin = "java-library") - apply(plugin = "maven-publish") - apply(plugin = "org.jetbrains.kotlin.jvm") - apply(plugin = "org.jetbrains.dokka") - apply(plugin = "com.gorylenko.gradle-git-properties") - apply(plugin = "ca.solo-studios.nyx") - - nyx { - // Project information - info { - group = "de.staropensource.engine" - version = buildString { - append(property("versionRelease") as String) - append("-") - append(property("versionType") as String) - append(property("versionTyperelease") as String) - - if (property("versionFork") != "") { - append(version) - append("-") - append(property("versionFork") as String) - } - - if (property("versionCompanion") != "") { - append(version) - append("-") - append(property("versionCompanion") as String) - } - } - description = this@allprojects.description ?: "The description of this sos!engine subsystem or subproject was not set" - organizationName = "The StarOpenSource Project" - organizationUrl = "hhttps://staropensource.de" - developer { - id = "staropensource" - name = "The StarOpenSource Project" - email = "support@staropensource.de" - url = "https://staropensource.de" - } - repository.fromGitHostWithIssues("StarOpenSource", "Engine", "https://git.staropensource.de", "sos!git") - license.useGPLv3() - } - - // Publishing - publishing { - withPublish() - repositories { - reposiliteMaven("https://mvn.staropensource.de/engine") { - name = "staropensource-engine" - credentials(PasswordCredentials::class) - } - } - } - - // Compilation - compile { - withAllWarnings() - withWarningsAsErrors() - withDistributeLicense() - encoding = "UTF-8" - withZip64() - withSuppressWarnings() - jvmToolchain = (property("languageJava") as String).toInt() - jvmTarget = (property("languageJava") as String).toInt() - withSourcesJar() - withJavadocJar() - withReproducibleBuilds() - - // Kotlin-specific settings - kotlin { - apiVersion = property("languageKotlin") as String - languageVersion = property("languageKotlin") as String - compilerArgs = listOf( - "-progressive" - ) - } - } - } - - // Repositories - repositories { - mavenLocal() - mavenCentral() - } - - // Dependencies - dependencies { - // Kotlin support - implementation("${property("dependencyKotlin_ReflectIdentifier") as String}:${property("dependencyKotlinVersion") as String}") - implementation("${property("dependencyKotlin_CoroutinesIdentifier") as String}:${property("dependencyKotlin_CoroutinesVersion") as String}") - implementation("${property("dependencyKotlin_DateTimeIdentifier") as String}:${property("dependencyKotlin_DateTimeVersion") as String}") - - // Unit testing - // -> Kotlin - testImplementation(kotlin("test")) - // -> JUnit - testImplementation(platform("${property("testDependencyJUnit_BOMIdentifier")}:${property("testDependencyJUnitVersion")}")) - testImplementation("${property("testDependencyJUnit_JupiterIdentifier")}") - testRuntimeOnly("${property("testDependencyJUnit_PlatformIdentifier")}") - // -> sos!engine - testImplementation(project(":testing")) - } - - // Unit testing - // -> Configure Gradle to use JUnit - tasks.test { - useJUnitPlatform() - - testLogging { - events( - "passed", - "skipped", - "failed" - ) - } - maxParallelForks = 1 - } - - // Dokka - tasks.withType().configureEach { - // Styling - val dokkaBaseConfiguration = """ - { - "_customAssets": ["${file("assets/my-image.png")}"], - "_customStyleSheets": ["${file("assets/my-styles.css")}"], - "footerMessage": "© 2024 The StarOpenSource Engine Authors. Licensed under the GNU Affero General Public License v3", - "_separateInheritedMembers": false, - "_templatesDir": "${file("dokka/templates")}", - "_mergeImplicitExpectActualDeclarations": false - } - """ - - pluginsMapConfiguration = mapOf( - "org.jetbrains.dokka.base.DokkaBase" to dokkaBaseConfiguration - ) - - // Configuration - moduleName = rootProject.name - moduleVersion = "v${this@allprojects.version as String}" - failOnWarning = true - suppressObviousFunctions = true - suppressInheritedMembers = true - - dokkaSourceSets.configureEach { - // Metadata - displayName = this@allprojects.name - documentedVisibilities = setOf(DokkaConfiguration.Visibility.PUBLIC, DokkaConfiguration.Visibility.PROTECTED) - reportUndocumented = false - skipEmptyPackages = false - skipDeprecated = false - jdkVersion = 21 - - // Source link - sourceLink { - localDirectory = this@allprojects.projectDir.resolve("src") - remoteUrl = URI("https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/" + this@allprojects.name.replace(":", "/") + "/src").toURL() - remoteLineSuffix = "#L" - } - } - } - - // Git properties - // -> Configure - gitProperties { - dotGitDirectory = file("${rootProject.rootDir}/.git") - failOnNoGitDirectory = false // Allow continuing if .git directory is missing (tarball) - extProperty = "git" - dateFormat = "yyyy-MM-dd'T'HH:mm:ss.S'Z'" - dateFormatTimeZone = "UTC" - } - - // -> Copy task - tasks.register("copyGitProperties") { - dependsOn(tasks.generateGitProperties) - inputs.file("${this@allprojects.projectDir}/build/resources/main/git.properties") - - doLast { - if (rootProject == this@allprojects) - return@doLast - - file(inputs.files.first()) - .copyTo( - file("${this@allprojects.projectDir}/src/main/resources/sosengine-${this@allprojects.name.replace(":", "-")}-git.properties"), - overwrite = true - ) - } - } - tasks.processResources { - dependsOn(tasks["copyGitProperties"]) - } - - // Gradle properties - // -> Copy task - tasks.register("copyGradleProperties") { - inputs.file("${rootProject.projectDir.path}/gradle.properties") - - doLast { - if (rootProject == project) - return@doLast - - file(inputs.files.first()) - .copyTo( - file("${this@allprojects.projectDir}/src/main/resources/sosengine-${this@allprojects.name.replace(":", "-")}-gradle.properties"), - overwrite = true - ) - } - } - tasks.processResources { - dependsOn(tasks["copyGradleProperties"]) - } + id("engine.generic") } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..2853596 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,55 @@ +/* + * STAROPENSOURCE ENGINE SOURCE FILE + * Copyright (c) 2025 The StarOpenSource Engine Authors + * Licensed under the GNU General Public License v3. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +// Plugins +plugins { + `kotlin-dsl` +} + +// Repositories +repositories { + mavenLocal() + mavenCentral() + maven { + name = "solostudios-releases" + setUrl("https://maven.solo-studios.ca/releases/") + } + gradlePluginPortal() +} + +// Dependencies +dependencies { + // Kotlin support + implementation("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:2.1.0") + + // Dokka + implementation("org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:1.9.20") + + // Git properties + implementation("com.gorylenko.gradle-git-properties:com.gorylenko.gradle-git-properties.gradle.plugin:2.4.2") + + // Nyx + implementation("ca.solo-studios.nyx:ca.solo-studios.nyx.gradle.plugin:0.2.3") + + // Native Image + implementation("org.mikeneck.graalvm-native-image:org.mikeneck.graalvm-native-image.gradle.plugin:v1.4.0") + + // Shadow + implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:8.3.5") +} diff --git a/buildSrc/src/main/kotlin/engine.application.gradle.kts b/buildSrc/src/main/kotlin/engine.application.gradle.kts new file mode 100644 index 0000000..abe299b --- /dev/null +++ b/buildSrc/src/main/kotlin/engine.application.gradle.kts @@ -0,0 +1,92 @@ +/* + * STAROPENSOURCE ENGINE SOURCE FILE + * Copyright (c) 2025 The StarOpenSource Engine Authors + * Licensed under the GNU General Public License v3. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +// Plugins +plugins { + application + + // Native image + id("org.mikeneck.graalvm-native-image") +} + +// Fix stdin +tasks.withType(JavaExec::class) { + standardInput = System.`in` +} + +// Configure application +application { + // JVM arguments + application.applicationDefaultJvmArgs = buildList { + // Unlock more VM options + add("-XX:+UnlockDiagnosticVMOptions") + add("-XX:+UnlockExperimentalVMOptions") + + // VM settings + // -> Log garbage collection + if ( + hasProperty("jvm.logGC") + && property("jvm.logGC") as String == "true" + ) + add("-Xlog:gc") + + // -> Log JIT & AOT + if ( + hasProperty("jvm.logJITandAOT") + && property("jvm.logJITandAOT") as String == "true" + ) { + add("-XX:+PrintCompilation") + add("-XX:+PrintInlining") + } + + // -> Select garbage collector + if (hasProperty("jvm.garbageCollector")) + when (property("jvm.garbageCollector")) { + "epsilon" -> add("-XX:+UseEpsilonGC") + "serial" -> add("-XX:+UseSerialGC") + "g1" -> add("-XX:+UseG1GC") + } + + // -> Manually added settings + if (hasProperty("jvm.args")) + addAll((property("jvm.args") as String).split(" ")) + } +} + +// GraalVM native-image +nativeImage { + outputs.upToDateWhen { true } + + // for some reason using Gradle properties does not work + graalVmHome = System.getProperty("graalHome", System.getProperty("java.home")) + executableName = "sosfurz-${name}" + outputDirectory = file("build/bin") + + arguments { + add("-H:+UnlockExperimentalVMOptions") + add("--color=always") + add("-march=native") + add("-O3") + add("--no-fallback") + add("--report-unsupported-elements-at-runtime") + add("--enable-http") + add("--enable-https") + add("-H:IncludeResources=.*properties\$") + } +} diff --git a/buildSrc/src/main/kotlin/engine.generic.gradle.kts b/buildSrc/src/main/kotlin/engine.generic.gradle.kts new file mode 100644 index 0000000..25d5624 --- /dev/null +++ b/buildSrc/src/main/kotlin/engine.generic.gradle.kts @@ -0,0 +1,214 @@ +/* + * STAROPENSOURCE ENGINE SOURCE FILE + * Copyright (c) 2025 The StarOpenSource Engine Authors + * Licensed under the GNU General Public License v3. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import ca.solostudios.nyx.util.reposiliteMaven +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.gradle.DokkaTask + +import java.net.URI + +// Utility +/** + * Local variable for the [getName] method + * for the `.properties` copying process. + */ +val projectName = name + +/** + * Local implementation of [property] + * for the `runTask` plugin configuration. + */ +private fun propertyLocal(propertyName: String): Any? = property(propertyName) + +// Plugins +plugins { + `java-library` + `maven-publish` + + // Kotlin support + id("org.jetbrains.kotlin.jvm") + + // Dokka + id("org.jetbrains.dokka") + + // Nyx + // Smol props to the creator of this plugin! + // solonovamax helped me (JeremyStarTM) + // heavily improve these build scripts + // thanks to their extended knowledge of + // the Gradle build system. + id("ca.solo-studios.nyx") +} + +nyx { + // Project information + info { + group = "de.staropensource.engine" + version = buildString { + append(propertyLocal("versionRelease") as String) + append("-") + append(propertyLocal("versionType") as String) + append(propertyLocal("versionTyperelease") as String) + + if (propertyLocal("versionFork") != "") { + append(version) + append("-") + append(propertyLocal("versionFork") as String) + } + + if (propertyLocal("versionCompanion") != "") { + append(version) + append("-") + append(propertyLocal("versionCompanion") as String) + } + } + organizationName = "The StarOpenSource Project" + organizationUrl = "hhttps://staropensource.de" + developer { + id = "staropensource" + name = "The StarOpenSource Project" + email = "support@staropensource.de" + url = "https://staropensource.de" + } + repository.fromGitHostWithIssues("StarOpenSource", "Engine", "https://git.staropensource.de", "sos!git") + license.useGPLv3() + } + + // Publishing + publishing { + withPublish() + repositories { + reposiliteMaven("https://mvn.staropensource.de/engine") { + name = "staropensource-engine" + credentials(PasswordCredentials::class) + } + } + } + + // Compilation + compile { + withAllWarnings() + withWarningsAsErrors() + withDistributeLicense() + encoding = "UTF-8" + withZip64() + withSuppressWarnings() + jvmToolchain = (propertyLocal("languageJava") as String).toInt() + jvmTarget = (propertyLocal("languageJava") as String).toInt() + withSourcesJar() + withJavadocJar() + withReproducibleBuilds() + + // Kotlin-specific settings + kotlin { + apiVersion = propertyLocal("languageKotlin") as String + languageVersion = propertyLocal("languageKotlin") as String + compilerArgs = listOf( + "-progressive" + ) + } + } +} + +// Repositories +repositories { + mavenLocal() + mavenCentral() +} + +// Dependencies +dependencies { + // Kotlin support + implementation("${propertyLocal("dependencyKotlin_ReflectIdentifier") as String}:${propertyLocal("dependencyKotlinVersion") as String}") + implementation("${propertyLocal("dependencyKotlin_CoroutinesIdentifier") as String}:${propertyLocal("dependencyKotlin_CoroutinesVersion") as String}") + implementation("${propertyLocal("dependencyKotlin_DateTimeIdentifier") as String}:${propertyLocal("dependencyKotlin_DateTimeVersion") as String}") + + // SLF4J + runtimeOnly("${propertyLocal("dependencySLF4J_NOPProviderIdentifier") as String}:${propertyLocal("dependencySLF4JVersion") as String}") + + // Unit testing + // -> Kotlin + testImplementation(kotlin("test")) + // -> JUnit + testImplementation(platform("${propertyLocal("testDependencyJUnit_BOMIdentifier")}:${propertyLocal("testDependencyJUnitVersion")}")) + testImplementation("${propertyLocal("testDependencyJUnit_JupiterIdentifier")}") + testRuntimeOnly("${propertyLocal("testDependencyJUnit_PlatformIdentifier")}") + // -> SLF4J + testRuntimeOnly("${propertyLocal("dependencySLF4J_NOPProviderIdentifier") as String}:${propertyLocal("dependencySLF4JVersion") as String}") + // -> sos!engine + testImplementation(project(":testing")) +} + +// Unit testing +// -> Configure Gradle to use JUnit +tasks.test { + useJUnitPlatform() + + testLogging { + events( + "passed", + "skipped", + "failed" + ) + } + maxParallelForks = 1 +} + +// Dokka +tasks.withType().configureEach { + // Styling + val dokkaBaseConfiguration = """ + { + "_customAssets": ["${file("assets/my-image.png")}"], + "_customStyleSheets": ["${file("assets/my-styles.css")}"], + "footerMessage": "© 2024 The StarOpenSource Engine Authors. Licensed under the GNU General Public License v3", + "_separateInheritedMembers": false, + "_templatesDir": "${file("dokka/templates")}", + "_mergeImplicitExpectActualDeclarations": false + } + """ + + pluginsMapConfiguration = mapOf( + "org.jetbrains.dokka.base.DokkaBase" to dokkaBaseConfiguration + ) + + // Configuration + moduleName = rootProject.name + moduleVersion = "v${version as String}" + failOnWarning = true + suppressObviousFunctions = true + suppressInheritedMembers = true + + dokkaSourceSets.configureEach { + // Metadata + displayName = projectName + documentedVisibilities = setOf(DokkaConfiguration.Visibility.PUBLIC, DokkaConfiguration.Visibility.PROTECTED) + reportUndocumented = false + skipEmptyPackages = false + skipDeprecated = false + jdkVersion = 21 + + // Source link + sourceLink { + localDirectory = projectDir.resolve("src") + remoteUrl = URI("https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/" + projectName.replace(":", "/") + "/src").toURL() + remoteLineSuffix = "#L" + } + } +} diff --git a/buildSrc/src/main/kotlin/engine.generic.properties.gradle.kts b/buildSrc/src/main/kotlin/engine.generic.properties.gradle.kts new file mode 100644 index 0000000..2607fe0 --- /dev/null +++ b/buildSrc/src/main/kotlin/engine.generic.properties.gradle.kts @@ -0,0 +1,77 @@ +/* + * STAROPENSOURCE ENGINE SOURCE FILE + * Copyright (c) 2025 The StarOpenSource Engine Authors + * Licensed under the GNU General Public License v3. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +// Utility +/** + * Local variable for the [getName] method + * for the `.properties` copying process. + */ +val projectName = name + +// Plugins +plugins { + `java-library` + + // Git properties + id("com.gorylenko.gradle-git-properties") +} + +// Git properties +// -> Configure +gitProperties { + dotGitDirectory = file("${rootProject.rootDir}/.git") + failOnNoGitDirectory = false // Allow continuing if .git directory is missing (tarball) + extProperty = "git" + dateFormat = "yyyy-MM-dd'T'HH:mm:ss.S'Z'" + dateFormatTimeZone = "UTC" +} + +// -> Copy task +tasks.register("copyGitProperties") { + dependsOn(tasks.generateGitProperties) + inputs.file("${projectDir}/build/resources/main/git.properties") + + doLast { + file(inputs.files.first()) + .copyTo( + file("${projectDir}/src/main/resources/sosengine-${projectName.replace(":", "-")}-git.properties"), + overwrite = true + ) + } +} +tasks.processResources { + dependsOn(tasks["copyGitProperties"]) +} + +// Gradle properties +// -> Copy task +tasks.register("copyGradleProperties") { + inputs.file("${rootDir.path}/gradle.properties") + + doLast { + file(inputs.files.first()) + .copyTo( + file("${projectDir}/src/main/resources/sosengine-${projectName.replace(":", "-")}-gradle.properties"), + overwrite = true + ) + } +} +tasks.processResources { + dependsOn(tasks["copyGradleProperties"]) +} diff --git a/gradle.properties b/gradle.properties index f5fe563..813f648 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,5 @@ -# # STAROPENSOURCE ENGINE SOURCE FILE -# Copyright (c) 2024 The StarOpenSource Engine Authors +# Copyright (c) 2025 The StarOpenSource Engine Authors # Licensed under the GNU General Public License v3. # # This program is free software: you can redistribute it and/or modify @@ -15,7 +14,6 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -# ### IMPORTANT NOTICE ### We handle dependencies in here instead @@ -48,10 +46,10 @@ versionCompanion= # Language versions languageJava=21 -languageKotlin=2.0 +languageKotlin=2.1 # Dependencies -dependencyKotlinVersion=2.0.21 +dependencyKotlinVersion=2.1.0 dependencyKotlin_ReflectIdentifier=org.jetbrains.kotlin:kotlin-reflect dependencyKotlin_CoroutinesIdentifier=org.jetbrains.kotlinx:kotlinx-coroutines-core dependencyKotlin_CoroutinesVersion=1.10.1 @@ -59,6 +57,8 @@ dependencyKotlin_DateTimeIdentifier=org.jetbrains.kotlinx:kotlinx-datetime dependencyKotlin_DateTimeVersion=0.6.1 dependencyOshiIdentifier=com.github.oshi:oshi-core-java11 dependencyOshiVersion=6.6.5 +dependencySLF4JVersion=2.0.16 +dependencySLF4J_NOPProviderIdentifier=org.slf4j:slf4j-nop # Test dependencies testDependencyJUnitVersion=5.11.3 diff --git a/settings.gradle.kts b/settings.gradle.kts index a69aae7..6502f60 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,6 @@ /* * STAROPENSOURCE ENGINE SOURCE FILE - * Copyright (c) 2024 The StarOpenSource Engine Authors + * Copyright (c) 2025 The StarOpenSource Engine Authors * Licensed under the GNU General Public License v3. * * This program is free software: you can redistribute it and/or modify @@ -17,19 +17,6 @@ * along with this program. If not, see . */ -// Plugin management -pluginManagement { - repositories { - mavenLocal() - mavenCentral() - gradlePluginPortal() - maven { - name = "solostudios-releases" - setUrl("https://maven.solo-studios.ca/releases/") - } - } -} - // Project settings rootProject.name = "sos!engine" diff --git a/testapp/build.gradle.kts b/testapp/build.gradle.kts index 90be08c..769fc91 100644 --- a/testapp/build.gradle.kts +++ b/testapp/build.gradle.kts @@ -1,6 +1,6 @@ /* * STAROPENSOURCE ENGINE SOURCE FILE - * Copyright (c) 2024 The StarOpenSource Engine Authors + * Copyright (c) 2025 The StarOpenSource Engine Authors * Licensed under the GNU General Public License v3. * * This program is free software: you can redistribute it and/or modify @@ -19,9 +19,9 @@ // Plugins plugins { - id("application") - id("org.mikeneck.graalvm-native-image") version("v1.4.0") - id("com.gradleup.shadow") version ("8.3.5") + id("engine.generic") + id("engine.generic.properties") + id("engine.application") } // Dependencies @@ -31,86 +31,7 @@ dependencies { implementation(project(":ansi")) } -// Configure JAR -tasks.withType { - manifest { - attributes["Main-Class"] = "de.staropensource.engine.testapp.Main" - } -} - -// Configure application -application { - mainClass = "de.staropensource.engine.testapp.Main" - - // JVM arguments - applicationDefaultJvmArgs = buildList { - // Unlock more VM options - add("-XX:+UnlockDiagnosticVMOptions") - add("-XX:+UnlockExperimentalVMOptions") - - // VM settings - // -> Log garbage collection - if ( - hasProperty("jvm.logGC") - && property("jvm.logGC") as String == "true" - ) - add("-Xlog:gc") - - // -> Log JIT & AOT - if ( - hasProperty("jvm.logJITandAOT") - && property("jvm.logJITandAOT") as String == "true" - ) { - add("-XX:+PrintCompilation") - add("-XX:+PrintInlining") - } - - // -> Select garbage collector - if (hasProperty("jvm.garbageCollector")) - when (property("jvm.garbageCollector")) { - "epsilon" -> add("-XX:+UseEpsilonGC") - "serial" -> add("-XX:+UseSerialGC") - "g1" -> add("-XX:+UseG1GC") - } - - // -> Manually added settings - if (hasProperty("jvm.args")) - addAll((property("jvm.args") as String).split(" ")) - - - // Jansi - add("-Djansi.mode=force") - } -} - -// Fix stdin -tasks.withType(JavaExec::class) { - standardInput = System.`in` -} - -// GraalVM native-image -nativeImage { - outputs.upToDateWhen { true } - - // for some reason using Gradle properties does not work - graalVmHome = System.getProperty("graalHome", System.getProperty("java.home")) - executableName = "sosengine-testapp" - outputDirectory = file("build/bin") - buildType { build -> - build.executable { - main = "de.staropensource.engine.testapp.Main" - } - } - - arguments { - add("-H:+UnlockExperimentalVMOptions") - add("--color=always") - add("-march=native") - add("-O3") - add("--no-fallback") - add("--report-unsupported-elements-at-runtime") - add("--enable-http") - add("--enable-https") - add("-H:IncludeResources=.*properties\$") - } -} +// Set main class +tasks.withType { manifest.attributes["Main-Class"] = "de.staropensource.engine.testapp.Main" } +application.mainClass = "de.staropensource.engine.testapp.Main" +nativeImage { buildType { it.executable.setMain("de.staropensource.engine.testapp.Main") } } diff --git a/testing/build.gradle.kts b/testing/build.gradle.kts index dd71b68..efd9b12 100644 --- a/testing/build.gradle.kts +++ b/testing/build.gradle.kts @@ -1,6 +1,6 @@ /* * STAROPENSOURCE ENGINE SOURCE FILE - * Copyright (c) 2024 The StarOpenSource Engine Authors + * Copyright (c) 2025 The StarOpenSource Engine Authors * Licensed under the GNU General Public License v3. * * This program is free software: you can redistribute it and/or modify @@ -17,6 +17,12 @@ * along with this program. If not, see . */ +// Plugins +plugins { + id("engine.generic") + id("engine.generic.properties") +} + // Dependencies dependencies { // sos!engine