wcloud/build.gradle.kts
2026-11-24 03:16:30 +01:00

214 lines
7.4 KiB
Plaintext

import com.diffplug.gradle.spotless.SpotlessExtension
import org.gradle.api.credentials.PasswordCredentials
plugins {
id("wcloud.parent-build-logic")
id("maven-publish")
alias(libs.plugins.spotless)
}
defaultTasks("build", "test", "shadowJar")
tasks.register<Zip>("webDistribution") {
group = "distribution"
description = "Packages a self-contained single-master wCloud installation and its modules."
archiveFileName.set("wcloud-web.zip")
destinationDirectory.set(layout.buildDirectory.dir("distributions"))
fun includeJar(projectPath: String, jarName: String, target: String) {
dependsOn("$projectPath:shadowJar")
from(project(projectPath).layout.buildDirectory.file("libs/$jarName")) { into(target) }
}
includeJar(":wcloud-launcher", Files.launcher, "")
includeJar(":wcloud-runnable:wcloud-master", Files.master, "dependency")
includeJar(":wcloud-api", Files.api, "local/GLOBAL/EVERY/plugins")
includeJar(":wcloud-plugin", Files.plugin, "local/GLOBAL/EVERY/plugins")
includeJar(":wcloud-modules:wmodule-permissions", Files.permissions, "modules")
includeJar(":wcloud-modules:wmodule-signs", Files.signs, "modules")
includeJar(":wcloud-modules:wmodule-npc", Files.npc, "modules")
includeJar(":wcloud-modules:wmodule-syncplayer", Files.syncplayer, "modules")
includeJar(":wcloud-modules:wmodule-cloudflare", Files.cloudflare, "optional-modules")
includeJar(":wcloud-modules:wmodule-discord", Files.discord, "optional-modules")
includeJar(":wcloud-modules:wmodule-hub", Files.hub, "optional-modules")
includeJar(":wcloud-modules:wmodule-notify", Files.notify, "optional-modules")
includeJar(":wcloud-modules:wmodule-reboot", Files.reboot, "optional-modules")
includeJar(":wcloud-modules:wmodule-syncproxy", Files.syncproxy, "modules")
includeJar(":wcloud-modules:wmodule-scoreboard", Files.scoreboard, "modules")
includeJar(":wcloud-modules:wmodule-moderation", Files.moderation, "optional-modules")
from("wcloud-launcher/src/main/dist")
}
allprojects {
version = Versions.wcloud
group = "de.wcloudservice"
description = "A modern application that can dynamically and easily deliver Minecraft oriented software"
repositories {
releasesOnly(mavenCentral())
// Prefer Maven Central over mirrors for release dependencies.
maven("https://repo.spongepowered.org/maven/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.opencollab.dev/main/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
// ensure that we use these repositories for snapshots/releases only (improves lookup times)
maven {
name = "repo"
url = uri("https://repo.jfritzsche.de/private")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
releasesOnly(maven("https://repo.jfritzsche.de/releases/"))
snapshotsOnly(maven("https://repo.jfritzsche.de/snapshots/"))
}
}
subprojects {
// these are top level projects which are configured separately
if (name == "wcloud-modules" || name == "wcloud-runnable") {
return@subprojects
}
// these are the plugins which we need to apply to all projects
apply(plugin = "signing")
apply(plugin = "maven-publish")
// skip further applying to bom - this project is a bit special as we're not allowed to
// apply the java plugin to it (that's why we need to stop here, but we need to publish
// at well (that's why we're applying the publish plugin)
if (name == "bom") {
return@subprojects
}
apply(plugin = "java-library")
apply(plugin = "com.diffplug.spotless")
dependencies {
// the 'rootProject.libs.' prefix is needed here - see https://github.com/gradle/gradle/issues/16634
// lombok
"compileOnly"(rootProject.libs.lombok)
"annotationProcessor"(rootProject.libs.lombok)
// annotations
"compileOnly"(rootProject.libs.annotations)
// testing
"testImplementation"(rootProject.libs.mockito)
"testRuntimeOnly"(rootProject.libs.junitLauncher)
"testImplementation"(rootProject.libs.bundles.junit)
"testImplementation"(rootProject.libs.bundles.testContainers)
}
configurations.all {
// unsure why but every project loves them, and they literally have an import for every letter I type - beware
exclude("org.checkerframework", "checker-qual")
}
/*
Todo: Add later
tasks.withType<Jar> {
from(rootProject.file("LICENSE"))
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
*/
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("started", "passed", "skipped", "failed")
}
// allow dynamic agent loading for mockito
jvmArgs(
"--enable-preview",
"-XX:+EnableDynamicAgentLoading",
"--add-opens=java.base/java.lang.invoke=ALL-UNNAMED"
)
// always pass down all given system properties
systemProperties(System.getProperties().mapKeys { it.key.toString() })
}
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(25)
options.encoding = "UTF-8"
options.isIncremental = true
}
tasks.withType<Checkstyle> {
maxErrors = 0
maxWarnings = 0
}
extensions.configure<SpotlessExtension> {
java {
googleJavaFormat("1.30.0").aosp().formatJavadoc(false).reorderImports(true)
formatAnnotations()
forbidWildcardImports()
licenseHeaderFile(rootProject.file("LICENSE_HEADER"))
}
}
tasks.register<org.gradle.jvm.tasks.Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(project.sourceSets()["main"].allJava)
}
tasks.withType<JavaCompile> {
dependsOn(tasks.withType<ProcessResources>())
}
if (name != "wcloud-api" && name != "wcloud-driver" && name != "wmodule-permissions" && name != "wcloud-utils" && name != "wcloud-networking") {
return@subprojects
}
publishing {
repositories {
maven {
name = "repo"
url = uri("https://repo.jfritzsche.de/releases")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
}
publications {
create<MavenPublication>("maven") {
from(components["java"])
groupId = "${project.group}"
artifactId = "${project.name}"
version = "${project.version}"
}
}
}
}
gradle.projectsEvaluated {
tasks.register("genUpdaterInformation") {
subprojects.forEach {
// check if we need to depend on the plugin
if (!it.plugins.hasPlugin("java")) return@forEach
// depend this task on the build output of each subproject
dependsOn("${it.path}:build")
}
// generate the updater information
doLast {
}
}
}