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") 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("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 { from(rootProject.file("LICENSE")) duplicatesStrategy = DuplicatesStrategy.INCLUDE } */ tasks.withType { 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 { toolchain.languageVersion.set(JavaLanguageVersion.of(25)) } tasks.withType().configureEach { options.release.set(25) options.encoding = "UTF-8" options.isIncremental = true } tasks.withType { maxErrors = 0 maxWarnings = 0 } extensions.configure { java { licenseHeaderFile(rootProject.file("LICENSE_HEADER")) } } tasks.register("sourcesJar") { archiveClassifier.set("sources") from(project.sourceSets()["main"].allJava) } tasks.withType { dependsOn(tasks.withType()) } 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("basic") } } } publications { create("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 { } } }