[build, minecraft] Publishing as Minecraft Fabric mods

This commit is contained in:
2025-08-03 15:58:55 +02:00
parent b5263c7a5c
commit f694672d5f
17 changed files with 251 additions and 3 deletions

View File

@@ -73,7 +73,7 @@ tasks.test {
publishing {
publications {
create<MavenPublication>("maven") {
create<MavenPublication>("lib") {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()

View File

@@ -8,6 +8,8 @@ plugins {
val expandedSourcesElements = configurations.consumable("expandedSourcesElements") {
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))
}
}
@@ -15,6 +17,8 @@ val expandedSourcesElements = configurations.consumable("expandedSourcesElements
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")

View File

@@ -0,0 +1,46 @@
plugins {
`maven-publish`
alias(libs.plugins.shadow)
id("de.siphalor.tweed5.expanded-sources-jar")
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,25 @@
plugins {
java
id("de.siphalor.tweed5.minecraft.mod.base")
}
val processMinecraftModResources = tasks.register<Copy>("processMinecraftModResources") {
from(project.layout.settingsDirectory.dir("minecraft/mod-template/resources"))
expand(
"id" to project.name,
"version" to project.version,
"name" to properties["minecraft.mod.name"],
"description" to properties["minecraft.mod.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)
}