Migrate to using Nyx

This commit is contained in:
JeremyStar™ 2024-12-25 01:03:09 +01:00
parent 524e1bcd1f
commit c671c23df0
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
4 changed files with 129 additions and 88 deletions

View file

@ -5,40 +5,6 @@ on:
- pull_request - pull_request
jobs: jobs:
build:
runs-on: docker
container:
image: git.staropensource.de/infrastructure/actions-docker:java
steps:
- name: Checkout
uses: https://code.forgejo.org/actions/checkout@v4
- name: Restore Gradle cache
uses: actions/cache/restore@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Compile
run: ./gradlew --no-daemon -Pjava.skipToolchainSpecification=true jar
- name: Save Gradle cache
uses: actions/cache/save@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Upload JARs
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: jars
path: |
**/build/libs/*.jar
if-no-files-found: error
test: test:
runs-on: docker runs-on: docker
container: container:
@ -66,6 +32,40 @@ jobs:
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: | restore-keys: |
gradle-${{ runner.os }}- gradle-${{ runner.os }}-
build-jars:
runs-on: docker
container:
image: git.staropensource.de/infrastructure/actions-docker:java
steps:
- name: Checkout
uses: https://code.forgejo.org/actions/checkout@v4
- name: Restore Gradle cache
uses: actions/cache/restore@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Compile
run: ./gradlew --no-daemon -Pjava.skipToolchainSpecification=true jar javadocJar sourcesJar
- name: Save Gradle cache
uses: actions/cache/save@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Upload JARs
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
with:
name: jars
path: |
**/build/libs/*.jar
if-no-files-found: error
build-apidoc: build-apidoc:
runs-on: docker runs-on: docker
container: container:

View file

@ -17,12 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import ca.solostudios.nyx.util.reposiliteMaven
import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.net.URI import java.net.URI
import java.nio.file.Files
import java.nio.file.LinkOption
/* /*
* STAROPENSOURCE ENGINE SOURCE FILE * STAROPENSOURCE ENGINE SOURCE FILE
@ -47,7 +45,6 @@ import java.nio.file.LinkOption
// Plugins // Plugins
plugins { plugins {
id("java-library") id("java-library")
id("maven-publish")
// Kotlin support // Kotlin support
id("org.jetbrains.kotlin.jvm") version("2.0.0") id("org.jetbrains.kotlin.jvm") version("2.0.0")
@ -57,23 +54,99 @@ plugins {
// Git properties // Git properties
id("com.gorylenko.gradle-git-properties") version("2.4.2") 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 { allprojects {
// Plugins // Plugins
apply(plugin = "java")
apply(plugin = "java-library") apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.dokka") apply(plugin = "org.jetbrains.dokka")
apply(plugin = "com.gorylenko.gradle-git-properties") apply(plugin = "com.gorylenko.gradle-git-properties")
apply(plugin = "ca.solo-studios.nyx")
// Version nyx {
version = "${property("versionRelease") as String}-${property("versionType") as String}${property("versionTyperelease") as String}" // Project information
if (property("versionFork") != "") info {
version = "${version as String}-${property("versionFork") as String}" name = this@allprojects.name
if (property("versionCompanion") != "") group = "de.staropensource.engine"
version = "${version as String}+${property("versionCompanion") as String}" module = this@allprojects.name
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
// Does not yet work, see
// https://github.com/solo-studios/nyx/issues/1
/*
publishing {
withPublish()
repositories {
reposiliteMaven("https://mvn.staropensource.de/engine") {
name = "staropensource-engine"
credentials(PasswordCredentials::class)
}
}
}
*/
// Compilation
compile {
withAllWarnings()
withWarningsAsErrors()
withDistributeLicense()
encoding = "UTF-8"
withZip64()
withBuildDependsOnJar()
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
repositories { repositories {
@ -84,8 +157,8 @@ allprojects {
// Dependencies // Dependencies
dependencies { dependencies {
// Kotlin support // Kotlin support
kotlin(property("dependencyKotlin_StdIdentifier") as String) //kotlin(property("dependencyKotlin_StdIdentifier") as String)
kotlin(property("dependencyKotlin_StdLibIdentifier") as String) //kotlin(property("dependencyKotlin_StdLibIdentifier") as String)
implementation("${property("dependencyKotlin_ReflectIdentifier") as String}:${property("dependencyKotlinVersion") as String}") implementation("${property("dependencyKotlin_ReflectIdentifier") as String}:${property("dependencyKotlinVersion") as String}")
implementation("${property("dependencyKotlin_DateTimeIdentifier") as String}:${property("dependencyKotlin_DateTimeVersion") as String}") implementation("${property("dependencyKotlin_DateTimeIdentifier") as String}:${property("dependencyKotlin_DateTimeVersion") as String}")
@ -100,29 +173,6 @@ allprojects {
testImplementation(project(":testing")) testImplementation(project(":testing"))
} }
// Java
java {
// Java version
sourceCompatibility = JavaVersion.toVersion(property("languageJava") as String)
targetCompatibility = JavaVersion.toVersion(property("languageJava") as String)
if (!(hasProperty("java.skipToolchainSpecification") && property("java.skipToolchainSpecification") as String == "true"))
toolchain {
languageVersion = JavaLanguageVersion.of(property("languageJava") as String)
}
}
// Kotlin
kotlin.compilerOptions {
// Configuration
progressiveMode = true
allWarningsAsErrors = true
verbose = true
// Set target metadata
jvmTarget = JvmTarget.fromTarget(property("languageJava") as String)
}
// Unit testing // Unit testing
// -> Configure Gradle to use JUnit // -> Configure Gradle to use JUnit
tasks.test { tasks.test {
@ -139,21 +189,6 @@ allprojects {
} }
// Dokka // Dokka
// -> Register jar generation tasks
// See https://kotlinlang.org/docs/dokka-gradle.html#build-javadoc-jar
tasks.register<Jar>("dokkaHtmlJar") {
dependsOn(tasks.dokkaHtml)
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
archiveClassifier.set("html-docs")
}
tasks.register<Jar>("dokkaJavadocJar") {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}
// -> Configure Dokka
tasks.withType<DokkaTask>().configureEach { tasks.withType<DokkaTask>().configureEach {
// Styling // Styling
val dokkaBaseConfiguration = """ val dokkaBaseConfiguration = """
@ -205,6 +240,7 @@ allprojects {
dateFormat = "yyyy-MM-dd'T'HH:mm:ss.S'Z'" dateFormat = "yyyy-MM-dd'T'HH:mm:ss.S'Z'"
dateFormatTimeZone = "UTC" dateFormatTimeZone = "UTC"
} }
// -> Copy task // -> Copy task
tasks.register("copyGitProperties") { tasks.register("copyGitProperties") {
dependsOn(tasks.generateGitProperties) dependsOn(tasks.generateGitProperties)
@ -226,7 +262,6 @@ allprojects {
} }
// Gradle properties // Gradle properties
// -> Copy task
tasks.register("copyGradleProperties") { tasks.register("copyGradleProperties") {
inputs.file("${project(":").projectDir.path}/gradle.properties") inputs.file("${project(":").projectDir.path}/gradle.properties")

View file

@ -34,7 +34,7 @@ versionCompanion=
# Language versions # Language versions
languageJava=21 languageJava=21
languageKotlin=2.1.0 languageKotlin=2.0
# Dependencies # Dependencies
dependencyKotlinVersion=2.1.0 dependencyKotlinVersion=2.1.0

View file

@ -1,3 +1,5 @@
import java.net.URI
/* /*
* STAROPENSOURCE ENGINE SOURCE FILE * STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors * Copyright (c) 2024 The StarOpenSource Engine Authors
@ -23,6 +25,10 @@ pluginManagement {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven {
name = "solostudios-releases"
setUrl("https://maven.solo-studios.ca/releases/")
}
} }
} }