feat(minecraft): Make every subproject its own mod

This commit is contained in:
2025-11-08 00:44:52 +01:00
parent 47ad406560
commit d2dada2b77
34 changed files with 186 additions and 65 deletions

View File

@@ -0,0 +1,46 @@
import de.siphalor.tweed5.gradle.plugin.minecraft.mod.MinecraftModded
plugins {
java
id("de.siphalor.tweed5.publishing")
id("de.siphalor.tweed5.minecraft.mod.base")
}
val minecraftJij = configurations.dependencyScope("minecraftJij")
val minecraftJijElements = configurations.named("minecraftJijElements") {
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
attribute(MinecraftModded.MINECRAFT_MODDED_ATTRIBUTE, objects.named(MinecraftModded.MODDED))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
}
extendsFrom(minecraftJij.get())
}
configurations.runtimeElements {
extendsFrom(minecraftJijElements.get())
}
configurations.apiElements {
extendsFrom(minecraftJijElements.get())
}
tasks.named<Jar>("jar") {
dependsOn(tasks.named("processMinecraftModResources"))
dependsOn(minecraftJijElements)
from(project.layout.buildDirectory.dir("minecraftModResources"))
from(minecraftJijElements) {
into("META-INF/jars")
}
}
publishing {
publications {
create<MavenPublication>("main") {
artifactId = project.name
version = project.version.toString()
from(components["java"])
}
}
}

View File

@@ -2,6 +2,7 @@ package de.siphalor.tweed5.minecraft.bundled.sources
import org.gradle.api.file.ArchiveOperations
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.bundling.Jar
@@ -17,5 +18,7 @@ abstract class BundledSourcesJar: Jar() {
@TaskAction
override fun copy() {
from(sources.filter { it.name.startsWith("tweed5") }.map { archiveOperations.zipTree(it) })
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
super.copy()
}
}

View File

@@ -0,0 +1,32 @@
import de.siphalor.tweed5.minecraft.bundled.sources.BundledSourcesJar
plugins {
id("de.siphalor.tweed5.minecraft.mod.bundle")
}
configurations.minecraftJijElements {
isTransitive = false
}
val bundledSourcesConfiguration = configurations.resolvable("bundledSources") {
extendsFrom(configurations.minecraftJijElements.get())
isTransitive = false
attributes {
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES))
}
}
dependencies {
minecraftJij("de.siphalor.tweed5:tweed5-annotation-inheritance")
minecraftJij("de.siphalor.tweed5:tweed5-naming-format")
minecraftJij("de.siphalor.tweed5:tweed5-type-utils")
minecraftJij("de.siphalor.tweed5:tweed5-weaver-pojo")
minecraftJij("de.siphalor.tweed5:tweed5-weaver-pojo-attributes-extension")
minecraftJij("de.siphalor.tweed5:tweed5-weaver-pojo-presets-extension")
minecraftJij("de.siphalor.tweed5:tweed5-weaver-pojo-serde-extension")
minecraftJij("de.siphalor.tweed5:tweed5-weaver-pojo-validation-extension")
}
tasks.register<BundledSourcesJar>("sourcesJar") {
sources.from(bundledSourcesConfiguration)
archiveClassifier.set("sources")
}

View File

@@ -0,0 +1,3 @@
module.name = Tweed 5 Bundle
module.description = Bundle of pre-packaged Tweed modules \
that are usually required for your Minecraft mod config needs.

View File

@@ -1,7 +1,7 @@
import de.siphalor.tweed5.minecraft.bundled.sources.BundledSourcesJar
plugins {
id("de.siphalor.tweed5.minecraft.mod.dummy")
id("de.siphalor.tweed5.minecraft.mod.bundle")
}
val bundledSourcesConfiguration = configurations.resolvable("bundledSources") {
@@ -12,51 +12,12 @@ val bundledSourcesConfiguration = configurations.resolvable("bundledSources") {
}
}
configurations.implementation {
exclude(group = "commons-logging", module = "commons-logging")
}
val vendoredCommonsLogging = project.layout.settingsDirectory.file("vendor/commons-logging").asFile
dependencies {
implementation("de.siphalor.tweed5:tweed5-core")
implementation("de.siphalor.tweed5:tweed5-attributes-extension")
implementation("de.siphalor.tweed5:tweed5-default-extensions")
implementation("de.siphalor.tweed5:tweed5-serde-extension")
implementation("de.siphalor.tweed5:tweed5-weaver-pojo")
implementation("de.siphalor.tweed5:tweed5-weaver-pojo-attributes-extension")
implementation("de.siphalor.tweed5:tweed5-weaver-pojo-presets-extension")
implementation("de.siphalor.tweed5:tweed5-weaver-pojo-serde-extension")
implementation("de.siphalor.tweed5:tweed5-weaver-pojo-validation-extension")
implementation(
objects.fileCollection().apply {
from(
vendoredCommonsLogging.resolve("target")
.listFiles { it.name.endsWith("SNAPSHOT.jar") }
)
builtBy("compileCommonsLogging")
}
)
}
tasks.register<Exec>("compileCommonsLogging") {
inputs.file(vendoredCommonsLogging.resolve("pom.xml"))
inputs.dir(vendoredCommonsLogging.resolve("src"))
outputs.dir(vendoredCommonsLogging.resolve("target"))
commandLine("mvn", "package", "-DskipTests")
workingDir(vendoredCommonsLogging)
}
tasks.shadowJar {
relocate("org.objectweb.asm", "de.siphalor.tweed5.shadowed.org.objectweb.asm")
relocate("META-INF", "META-INF/tweed5-vendored/commons-logging") {
include("META-INF/*.txt")
}
exclude("META-INF/maven/**")
// Remove some obsolete classes
exclude("org/apache/commons/logging/impl/WeakHashtable*")
minecraftJij("de.siphalor.tweed5:tweed5-core")
minecraftJij("de.siphalor.tweed5:tweed5-attributes-extension")
minecraftJij("de.siphalor.tweed5:tweed5-default-extensions")
minecraftJij("de.siphalor.tweed5:tweed5-serde-extension")
minecraftJij(project(":tweed5-logging"))
}
tasks.register<BundledSourcesJar>("sourcesJar") {

View File

@@ -13,7 +13,9 @@ dependencies {
listOf("fabric-key-binding-api-v1", "fabric-resource-loader-v0").forEach {
modTestmodImplementation(fabricApi.module(it, mcLibs.versions.fabric.api.get()))
}
testmodImplementation(project(":tweed5-bundle", configuration = "minecraftModElements"))
testmodImplementation(project(":tweed5-logging", configuration = "minecraftModApiElements"))
testmodImplementation(project(":tweed5-bundle", configuration = "runtimeElements"))
testmodImplementation(project(":tweed5-bundle-pojo-weaving", configuration = "runtimeElements"))
testmodImplementation(project(":tweed5-fabric-helper", configuration = "namedElements"))
modTestmodImplementation(mcLibs.coat)
modTestmodImplementation(mcLibs.amecs.api)

View File

@@ -19,7 +19,7 @@ dependencies {
listOf("fabric-networking-api-v1", "fabric-lifecycle-events-v1").forEach {
modTestmodImplementation(fabricApi.module(it, mcLibs.versions.fabric.api.get()))
}
testmodImplementation(project(":tweed5-bundle", configuration = "minecraftModElements"))
testmodImplementation(project(":tweed5-bundle"))
testmodImplementation("de.siphalor.tweed5:tweed5-comment-loader-extension")
testmodImplementation("de.siphalor.tweed5:tweed5-serde-hjson")
testmodImplementation("de.siphalor.tweed5:tweed5-serde-gson")

View File

@@ -0,0 +1,32 @@
plugins {
id("de.siphalor.tweed5.minecraft.mod.dummy")
}
val vendoredCommonsLogging = project.layout.settingsDirectory.file("vendor/commons-logging").asFile
dependencies {
shadowOnly(objects.fileCollection().apply {
from(
vendoredCommonsLogging.resolve("target")
.listFiles { it.name.endsWith("SNAPSHOT.jar") }
)
builtBy("compileCommonsLogging")
})
}
tasks.register<Exec>("compileCommonsLogging") {
inputs.file(vendoredCommonsLogging.resolve("pom.xml"))
inputs.dir(vendoredCommonsLogging.resolve("src"))
outputs.dir(vendoredCommonsLogging.resolve("target"))
commandLine("mvn", "package", "-DskipTests")
workingDir(vendoredCommonsLogging)
}
tasks.shadowJar {
relocate("META-INF", "META-INF/tweed5-vendored/commons-logging") {
include("META-INF/*.txt")
}
exclude("META-INF/maven/**")
// Remove some obsolete classes
exclude("org/apache/commons/logging/impl/WeakHashtable*")
}

View File

@@ -0,0 +1,4 @@
module.name = Tweed 5 Logging
module.description = Fork and relocation of Apache Commons Logging.\n\
Contains a small fix to support older Log4j versions. \
Also removes some obsolete classes.

View File

@@ -33,5 +33,6 @@
"authors": [
"Siphalor"
],
"version": "${version}"
"version": "${version}",
"jars": [${jars}]
}

View File

@@ -52,8 +52,10 @@ dependencyResolutionManagement {
includeBuild("../tweed5")
includeNormalModule("bundle")
includeNormalModule("bundle-pojo-weaving")
includeNormalModule("coat-bridge")
includeNormalModule("fabric-helper")
includeNormalModule("logging")
fun includeNormalModule(name: String) {
includeAs("tweed5-$name", name)