[build] Restructure to composite build

This commit is contained in:
2025-10-26 02:03:53 +02:00
parent 0e3990aed9
commit 1fbc97866c
348 changed files with 126 additions and 64 deletions

View File

@@ -0,0 +1,84 @@
plugins {
java
`java-library`
jacoco
alias(libs.plugins.lombok)
id("de.siphalor.tweed5.publishing")
id("de.siphalor.tweed5.local-runtime-only")
id("de.siphalor.tweed5.expanded-sources-jar")
}
java {
sourceCompatibility = JavaVersion.toVersion(libs.versions.java.main.get())
targetCompatibility = JavaVersion.toVersion(libs.versions.java.main.get())
}
val testAgent = configurations.dependencyScope("mockitoAgent")
val testAgentClasspath = configurations.resolvable("testAgentClasspath") {
isTransitive = false
extendsFrom(testAgent.get())
}
lombok {
version = libs.versions.lombok.get()
}
dependencies {
compileOnly(libs.autoservice.annotations)
annotationProcessor(libs.autoservice.processor)
testCompileOnly(libs.autoservice.annotations)
testAnnotationProcessor(libs.autoservice.processor)
compileOnly(libs.jetbrains.annotations)
testImplementation(libs.jetbrains.annotations)
compileOnly(libs.jspecify.annotations)
testImplementation(libs.jspecify.annotations)
implementation(libs.acl)
"localRuntimeOnly"(libs.slf4j.rt)
testImplementation(libs.acl)
testImplementation(libs.slf4j.rt)
testImplementation(platform(libs.junit.platform))
testImplementation(libs.junit.core)
testRuntimeOnly(libs.junit.launcher)
testImplementation(libs.mockito)
testAgent(libs.mockito)
testImplementation(libs.assertj)
testImplementation(project(":generic-test-utils"))
}
tasks.compileTestJava {
sourceCompatibility = libs.versions.java.test.get()
targetCompatibility = libs.versions.java.test.get()
}
tasks.test {
dependsOn(testAgentClasspath)
finalizedBy(tasks.jacocoTestReport)
useJUnitPlatform()
jvmArgs(testAgentClasspath.get().files.map { file -> "-javaagent:${file.absolutePath}" })
systemProperties(
"junit.jupiter.execution.timeout.mode" to "disabled_on_debug",
"junit.jupiter.execution.timeout.testable.method.default" to "10s",
"junit.jupiter.execution.timeout.thread.mode.default" to "SEPARATE_THREAD",
)
}
tasks.jacocoTestReport {
dependsOn(tasks.test)
}
publishing {
publications {
create<MavenPublication>("lib") {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from(components["java"])
}
}
}

View File

@@ -0,0 +1,34 @@
import io.freefair.gradle.plugins.lombok.tasks.Delombok
plugins {
java
`java-library`
alias(libs.plugins.lombok)
}
val expandedSourcesElements = configurations.consumable("expandedSourcesElements") {
extendsFrom(configurations.implementation.get())
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES))
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
val delombok = tasks.getByName<Delombok>("delombok")
val sourcesJar by tasks.registering(Jar::class) {
group = LifecycleBasePlugin.BUILD_GROUP
dependsOn(delombok)
from(delombok.target)
archiveClassifier.set("sources")
}
artifacts.add(expandedSourcesElements.name, sourcesJar)
tasks.named("build") { dependsOn(sourcesJar) }
components.named<AdhocComponentWithVariants>("java") {
addVariantsFromConfiguration(expandedSourcesElements.get()) {}
}

View File

@@ -0,0 +1,6 @@
plugins {
java
}
val localRuntimeOnly = configurations.create("localRuntimeOnly")
sourceSets.main.get().runtimeClasspath += localRuntimeOnly

View File

@@ -0,0 +1,47 @@
plugins {
`maven-publish`
alias(libs.plugins.shadow)
java
`java-library`
id("de.siphalor.tweed5.minecraft.mod.component")
}
tasks.shadowJar {
relocate("org.apache.commons", "de.siphalor.tweed5.shadowed.org.apache.commons")
}
val minecraftModJar = tasks.register<Jar>("minecraftModJar") {
group = LifecycleBasePlugin.BUILD_GROUP
from(zipTree(tasks.shadowJar.get().archiveFile))
destinationDirectory.set(layout.buildDirectory.dir("minecraftModLibs"))
}
tasks.assemble {
dependsOn(minecraftModJar)
}
val minecraftModSourcesJar = tasks.register<Jar>("minecraftModSourcesJar") {
group = LifecycleBasePlugin.BUILD_GROUP
from(zipTree(tasks.named<Jar>("sourcesJar").get().archiveFile))
archiveClassifier = "sources"
destinationDirectory.set(layout.buildDirectory.dir("minecraftModLibs"))
}
artifacts.add("minecraftModElements", minecraftModJar)
artifacts.add("minecraftModSourcesElements", minecraftModSourcesJar)
publishing {
publications {
create<MavenPublication>("minecraftMod") {
groupId = "${project.group}.minecraft"
artifactId = project.name
version = project.version.toString()
from(components["minecraftMod"])
}
}
}

View File

@@ -0,0 +1,29 @@
plugins {
id("de.siphalor.tweed5.minecraft.mod.base")
}
val processMinecraftModResources = tasks.register<Copy>("processMinecraftModResources") {
inputs.property("id", project.name)
inputs.property("version", project.version)
inputs.property("name", properties["module.name"])
inputs.property("description", properties["module.description"])
from(project.layout.settingsDirectory.dir("../tweed5-minecraft/mod-template/resources"))
expand(mapOf(
"id" to project.name,
"version" to project.version,
"name" to properties["module.name"],
"description" to properties["module.description"]
))
into(project.layout.buildDirectory.dir("minecraftModResources"))
}
tasks.named<Jar>("minecraftModJar") {
from(project.layout.buildDirectory.dir("minecraftModResources"))
dependsOn(processMinecraftModResources)
}
tasks.named<Jar>("minecraftModSourcesJar") {
from(project.layout.buildDirectory.dir("minecraftModResources"))
dependsOn(processMinecraftModResources)
}

View File

@@ -0,0 +1,35 @@
plugins {
`java-library`
`maven-publish`
}
group = rootProject.group
version = rootProject.version
publishing {
repositories {
if (project.hasProperty("siphalor.maven.user")) {
maven {
name = "Siphalor"
url = uri("https://maven.siphalor.de/upload.php")
credentials {
username = project.property("siphalor.maven.user") as String
password = project.property("siphalor.maven.password") as String
}
}
}
}
publications.all {
if (this is MavenPublication) {
pom {
name = project.property("module.name") as String
description = project.property("module.description") as String
url = project.property("git.url") as String
scm {
url = project.property("git.url") as String
}
}
}
}
}

View File

@@ -0,0 +1,5 @@
import java.util.Properties
val rootProperties = Properties()
project.layout.settingsDirectory.file("../gradle.properties").asFile.inputStream().use { rootProperties.load(it) }
rootProperties.forEach { (key, value) -> project.ext.set(key.toString(), value.toString()) }

View File

@@ -0,0 +1,14 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
alias(libs.plugins.shadow)
}
val shadowOnlyConfiguration = configurations.dependencyScope("shadowOnly")
val shadowOnlyElementsConfiguration = configurations.resolvable("shadowOnlyElements") {
extendsFrom(shadowOnlyConfiguration.get())
}
tasks.named<ShadowJar>("shadowJar") {
configurations = listOf(shadowOnlyElementsConfiguration.get())
}

View File

@@ -0,0 +1,21 @@
plugins {
java
alias(libs.plugins.lombok)
}
dependencies {
implementation(project(":tweed5-serde-api"))
implementation(platform(libs.junit.platform))
implementation(libs.junit.core)
implementation(libs.mockito)
implementation(libs.assertj)
}
lombok {
version = libs.versions.lombok.get()
}
java {
sourceCompatibility = JavaVersion.toVersion(libs.versions.java.test.get())
targetCompatibility = JavaVersion.toVersion(libs.versions.java.test.get())
}