Migrate to convention build scripts

This commit is contained in:
JeremyStar™ 2025-01-09 22:00:48 +01:00
parent ddeb651a77
commit 151afaad40
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
9 changed files with 529 additions and 186 deletions

View file

@ -16,28 +16,3 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Plugins
plugins {}
// Set group, version and repositories for all projects
allprojects {
group = project.group
version = project.versioningVersion + "-" + project.versioningType + project.versioningTyperelease + project.versioningFork + "+" + project.minecraftVersion
repositories {
mavenCentral()
maven {
name = "staropensource-engine"
url = "https://mvn.staropensource.de/engine"
}
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
}

59
buildSrc/build.gradle.kts Normal file
View file

@ -0,0 +1,59 @@
/*
* PICKSHADOW SERVER KIT SOURCE FILE
* Copyright (c) 2025 The PickShadow Server Kit authors
* Licensed under the GNU Affero General Public License v3
*
* 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 <https://www.gnu.org/licenses/>.
*/
import java.net.URI
// Plugins
plugins {
`kotlin-dsl`
}
// Repositories
repositories {
mavenLocal()
gradlePluginPortal()
mavenCentral()
}
// 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")
// Lombok
implementation("io.freefair.lombok:io.freefair.lombok.gradle.plugin:8.10.2")
// Run Task
implementation("xyz.jpenilla.run-paper:xyz.jpenilla.run-paper.gradle.plugin:2.3.1")
// Paperweight
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.7")
// Shadow
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:8.3.5")
}

View file

@ -0,0 +1,250 @@
/*
* PICKSHADOW SERVER KIT SOURCE FILE
* Copyright (c) 2025 The PickShadow Server Kit authors
* Licensed under the GNU Affero General Public License v3
*
* 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 <https://www.gnu.org/licenses/>.
*/
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.gradle.DokkaTask
import java.net.URI
plugins {
// Kotlin support
id("org.jetbrains.kotlin.jvm")
// Dokka
id("org.jetbrains.dokka")
// Git properties
id("com.gorylenko.gradle-git-properties")
// Nyx
id("ca.solo-studios.nyx")
}
nyx {
// Project information
info {
group = "de.staropensource.pickshadow"
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)
}
}
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("JeremyStarTM", "PickShadow", "https://git.staropensource.de", "sos!git")
license.useGPLv3()
}
// 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()
maven {
name = "staropensource-engine"
url = URI("https://mvn.staropensource.de/engine")
}
maven {
name = "papermc-repo"
url = URI("https://repo.papermc.io/repository/maven-public/")
}
maven {
name = "sonatype"
url = URI("https://oss.sonatype.org/content/groups/public/")
}
}
// Dependencies
dependencies {
// Kotlin support
compileOnly(
property("dependencyKotlin_ReflectIdentifier") as String +
":" +
property("dependencyKotlinVersion") as String
)
compileOnly(
property("dependencyKotlin_CoroutinesIdentifier") as String +
":" +
property("dependencyKotlin_CoroutinesVersion") as String
)
compileOnly(
property("dependencyKotlin_DateTimeIdentifier") as String +
":" +
property("dependencyKotlin_DateTimeVersion") as String
)
// StarOpenSource Engine
compileOnly(
property("dependencyStarOpenSource_Engine_BaseIdentifier") as String +
":" +
property("dependencyStarOpenSource_EngineVersion") as String
)
}
// Unit testing
// -> Configure Gradle to use JUnit
tasks.test {
useJUnitPlatform()
testLogging {
events(
"passed",
"skipped",
"failed"
)
}
maxParallelForks = 1
}
// Dokka
tasks.withType<DokkaTask>().configureEach {
// Styling
val dokkaBaseConfiguration = """
{
"_customAssets": ["${file("assets/my-image.png")}"],
"_customStyleSheets": ["${file("assets/my-styles.css")}"],
"footerMessage": "&copy; 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 = "PSSK"
moduleVersion = "v${version as String}"
failOnWarning = true
suppressObviousFunctions = true
suppressInheritedMembers = true
dokkaSourceSets.configureEach {
// Metadata
displayName = name
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/" +
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("${projectDir}/build/resources/main/git.properties")
doLast {
file(inputs.files.first())
.copyTo(
file("${projectDir}/src/main/resources/pickshadow-${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("${projectDir}/src/main/resources/pickshadow-${name.replace(":", "-")}-gradle.properties"),
overwrite = true
)
}
}
tasks.processResources {
dependsOn(tasks["copyGradleProperties"])
}

View file

@ -0,0 +1,51 @@
/*
* PICKSHADOW SERVER KIT SOURCE FILE
* Copyright (c) 2025 The PickShadow Server Kit authors
* Licensed under the GNU Affero General Public License v3
*
* 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 <https://www.gnu.org/licenses/>.
*/
plugins {
// Java
java
// Kotlin support
id("org.jetbrains.kotlin.jvm")
// Lombok
id("io.freefair.lombok")
}
// Dependencies
dependencies {
// Lombok
compileOnly(
property("dependencyLombokIdentifier") as String +
":" +
property("dependencyLombokVersion") as String
)
annotationProcessor(
property("dependencyLombokIdentifier") as String +
":" +
property("dependencyLombokVersion") as String
)
// JetBrains Annotations
compileOnly(
property("dependencyJetbrainsAnnotationsIdentifier") as String +
":" +
property("dependencyJetbrainsAnnotationsVersion") as String
)
}

View file

@ -0,0 +1,104 @@
import gradle.kotlin.dsl.accessors._c7ea62deb6a31fe057ec25b5e4aa3209.compileOnly
import gradle.kotlin.dsl.accessors._c7ea62deb6a31fe057ec25b5e4aa3209.processResources
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
/*
* PICKSHADOW SERVER KIT SOURCE FILE
* Copyright (c) 2025 The PickShadow Server Kit authors
* Licensed under the GNU Affero General Public License v3
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* Local implementation of [property]
* for the `runTask` plugin configuration.
*/
private fun propertyLocal(propertyName: String): Any? = property(propertyName)
plugins {
id("xyz.jpenilla.run-paper")
id("io.papermc.paperweight.userdev")
}
// Dependencies
dependencies {
// Paper API
compileOnly(
property("dependencyPaper_APIIdentifier") as String +
":" +
property("minecraftMajor") as String +
property("minecraftMinor") as String +
"-" +
property("dependencyPaper_APIVersion")
)
// Adventure
compileOnly(
"net.kyori:adventure-api:" +
property("dependencyAdventure") as String
)
// NMS
paperweight.paperDevBundle(
property("minecraftMajor") as String +
property("minecraftMinor") as String +
"-" +
property("dependencyPaper_APIVersion") as String
)
}
// Paperweight
paperweight {
reobfArtifactConfiguration = ReobfArtifactConfiguration.MOJANG_PRODUCTION
}
// Allow plugin.yml to use properties in gradle.properties
tasks.processResources {
filesMatching("plugin.yml") {
expand(properties)
}
}
// Configure server
tasks.runServer {
minecraftVersion(
propertyLocal("minecraftMajor") as String +
propertyLocal("minecraftMinor") as String
)
jvmArguments.addAll(
"-Dfile.encoding=UTF-8",
"-Dcom.mojang.eula.agree=true",
"-Dsosengine.base.logLevel=diagnostic",
"-Dpickshadow.extension.enabledModes=general,survival,survivalcheat"
)
downloadPlugins {
url("https://git.staropensource.de/StarOpenSource/EngineMC/releases/download/v1-release3/bukkit.jar")
url("https://download.luckperms.net/1561/bukkit/loader/LuckPerms-Bukkit-5.4.146.jar")
url("https://ci.lucko.me/job/spark/464/artifact/spark-bukkit/build/libs/spark-1.10.118-bukkit.jar")
modrinth("freedomchat", "NdbpBqOZ")
}
doFirst {
// Disable bStats
val config: File = runDirectory.get().asFile.resolve("/plugins/bStats/config.yml")
if (!config.exists()) {
config.parentFile.mkdirs()
config.createNewFile()
config.writeText("enabled: false\n")
}
}
}

View file

@ -0,0 +1,22 @@
/*
* PICKSHADOW SERVER KIT SOURCE FILE
* Copyright (c) 2025 The PickShadow Server Kit authors
* Licensed under the GNU Affero General Public License v3
*
* 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 <https://www.gnu.org/licenses/>.
*/
plugins {
id("com.gradleup.shadow")
}

View file

@ -1,4 +1,3 @@
/*
* PICKSHADOW SERVER KIT SOURCE FILE
* Copyright (c) 2024 The PickShadow Server Kit authors
@ -18,69 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import java.nio.file.Files
// Plugins
plugins {
id("java")
id("io.freefair.lombok") version("${pluginLombok}")
id("com.gorylenko.gradle-git-properties") version("${pluginGitProperties}")
id("pickshadow.generic")
id("pickshadow.java")
}
// Dependencies
dependencies {
// Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
// JetBrains Annotations
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// Libraries
compileOnly("de.staropensource.engine:base:${dependencyStarOpenSourceEngine}")
}
// Set Java version
java {
toolchain.languageVersion.set(JavaLanguageVersion.of("${javaTarget}"))
}
// Git properties configuration
// Allows us to embed git commit information in the plugin build
gitProperties {
dotGitDirectory = file("${rootProject.rootDir}/.git")
failOnNoGitDirectory = false // Allow continuing if .git directory is missing for the few who use tarballs
extProperty = "gitProps"
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "UTC"
}
tasks.register("writeGitProperties") { // This task's only purpose is to copy the git.properties from our git properties plugin to the resources directory so it's included in the final build
doLast {
File target = file("${project.projectDir}/src/main/resources/pickshadow-git.properties")
File source = file("${project.projectDir}/build/resources/main/git.properties")
target.delete()
source.renameTo(target)
}
outputs.upToDateWhen({ false }) // Force task execution
}
generateGitProperties.outputs.upToDateWhen({ false }) // Force task execution
processResources.dependsOn(writeGitProperties) // Ensure git.properties file is present
// Copy gradle.properties file for inclusion in final build
tasks.register("copyGradleProperties") {
doFirst {
File target = file("${project.projectDir}/src/main/resources/pickshadow-gradle.properties")
File source = file(project(":").projectDir.getPath() + "/gradle.properties")
target.delete()
Files.copy(source.toPath(), target.toPath())
}
outputs.upToDateWhen({ false }) // Force task execution
}
processResources.dependsOn(copyGradleProperties)

View file

@ -17,36 +17,19 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
// Plugins
plugins {
id("java")
id("io.freefair.lombok") version("${pluginLombok}")
id("io.papermc.paperweight.userdev") version("${pluginPaperweight}")
id("io.github.goooler.shadow") version("${pluginShadow}")
id("xyz.jpenilla.run-paper") version("${pluginRunTask}")
id("pickshadow.generic")
id("pickshadow.java")
id("pickshadow.papermc")
id("pickshadow.shadow")
}
// Dependencies
dependencies {
// Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
// JetBrains Annotations
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// Libraries
compileOnly("de.staropensource.engine:base:${dependencyStarOpenSourceEngine}")
runtimeOnly("de.staropensource.enginemc:platform-bukkit:${dependencyStarOpenSourceEngineMC}")
// GSON
implementation("com.google.code.gson:gson:${dependencyGson}")
// Server
compileOnly("io.papermc.paper:paper-api:${minecraftVersion}-${dependencyPaper}-SNAPSHOT")
compileOnly("net.kyori:adventure-api:${dependencyAdventure}")
paperweight.paperDevBundle("${minecraftVersion}-${dependencyPaper}-SNAPSHOT")
// Plugins
compileOnly("net.luckperms:api:${dependencyLuckPerms}")
@ -56,49 +39,3 @@ dependencies {
// Project
implementation(project(":common"))
}
// Set Java version
java {
toolchain.languageVersion.set(JavaLanguageVersion.of("${javaTarget}"))
}
// Update plugin.yml
processResources {
filesMatching("plugin.yml") {
expand project.properties
}
}
// Configure paperweight
paperweight {
reobfArtifactConfiguration = ReobfArtifactConfiguration.getMOJANG_PRODUCTION()
}
// Configure server
runServer {
minecraftVersion("${minecraftVersion}")
jvmArguments.addAll(
"-Dfile.encoding=UTF-8",
"-Dcom.mojang.eula.agree=true",
"-Dsosengine.base.logLevel=diagnostic",
"-Dpickshadow.extension.enabledModes=general,survival,survivalcheat"
)
downloadPlugins {
url("${downloadEngineMC}")
url("${downloadLuckPerms}")
url("${downloadSpark}")
modrinth("freedomchat", "${downloadFreedomChat}")
}
doFirst {
// Disable bStats
File config = new File(runDirectory.get().getAsFile().getPath() + "/plugins/bStats/config.yml")
if (!config.exists()) {
config.getParentFile().mkdirs()
config.createNewFile()
config.write("enabled: false\n")
}
}
}

View file

@ -1,4 +1,3 @@
#
# PICKSHADOW SERVER KIT SOURCE FILE
# Copyright (c) 2024 The PickShadow Server Kit Contributors
# Licensed under the GNU Affero General Public License v3
@ -15,47 +14,55 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Gradle properties
org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx1G -Xms1G -XX:MaxMetaspaceSize=1G -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.priority=normal
# Versioning
versioningCodename=Pulsar
versioningVersion=1
versioningType=alpha
versioningTyperelease=0
versioningFork=
versionCodename=Pulsar
versionRelease=1
versionType=alpha
versionTyperelease=0
versionFork=
versionCompanion=
# Java
javaSource=21
javaTarget=21
# Plugins
pluginLombok=8.10.2
pluginShadow=8.1.8
pluginPaperweight=1.7.4
pluginGitProperties=2.4.2
pluginRunTask=2.3.1
languageJava=21
languageKotlin=2.1
# Dependencies
dependencyLombok=1.18.34
dependencyJetbrainsAnnotations=26.0.1
dependencyStarOpenSourceEngine=1-alpha8
dependencyStarOpenSourceEngineMC=1-release2
# -> Kotlin
dependencyKotlinVersion=2.1.0
dependencyKotlin_ReflectIdentifier=org.jetbrains.kotlin:kotlin-reflect
dependencyKotlin_CoroutinesIdentifier=org.jetbrains.kotlinx:kotlinx-coroutines-core
dependencyKotlin_CoroutinesVersion=1.10.1
dependencyKotlin_DateTimeIdentifier=org.jetbrains.kotlinx:kotlinx-datetime
dependencyKotlin_DateTimeVersion=0.6.1
# -> StarOpenSource Engine
dependencyStarOpenSource_EngineVersion=1-alpha10
dependencyStarOpenSource_Engine_BaseIdentifier=de.staropensource.engine:base
# -> Java support
dependencyLombokVersion=1.18.34
dependencyLombokIdentifier=org.projectlombok:lombok
dependencyJetbrainsAnnotationsVersion=26.0.1
dependencyJetbrainsAnnotationsIdentifier=org.jetbrains:annotations
# -> Bukkit
dependencyPaper_APIIdentifier=io.papermc.paper:paper-api
dependencyPaper_APIVersion=R0.1-SNAPSHOT
# -> Legacy format
dependencyHikari=6.1.0
dependencyGson=2.11.0
dependencyPaper=R0.1
dependencyAdventure=4.17.0
dependencyLuckPerms=5.4
dependencyFastboard=2.1.3
# Minecraft
minecraftVersion=1.21.3
minecraftApi=1.21
# Plugin download metadata
downloadEngineMC=https://git.staropensource.de/StarOpenSource/EngineMC/releases/download/v1-release3/bukkit.jar
downloadLuckPerms=https://download.luckperms.net/1561/bukkit/loader/LuckPerms-Bukkit-5.4.146.jar
downloadSpark=https://ci.lucko.me/job/spark/464/artifact/spark-bukkit/build/libs/spark-1.10.118-bukkit.jar
downloadFreedomChat=NdbpBqOZ
minecraftMajor=1.21
minecraftMinor=.3
# etc
group = de.staropensource.pickshadow