Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ build/
# Gradle Patch
**/build/

# Mapping generator outputs
/mapping/build/

# Common working directory
run/

Expand Down
5 changes: 2 additions & 3 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ publishing {
}
}

artifacts {
archives(javadocJar)
archives(sourcesJar)
tasks.named("assemble") {
dependsOn(javadocJar, sourcesJar)
}

@Suppress("UNCHECKED_CAST")
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ minecraft-velocity = "3.5.0-SNAPSHOT" # https://github.com/PaperMC/Velocity
tool-commons-io = "2.6" # https://github.com/apache/commons-io
tool-fastutil = "8.5.11" # https://github.com/vigna/fastutil/
tool-google-guava = "28.0-jre" # https://github.com/google/guava
tool-google-gson = "2.13.2" # https://github.com/google/gson
tool-netty = "4.1.86.Final" # https://github.com/netty/netty
tool-spotbugs-annotations = "4.7.3" # https://github.com/spotbugs/spotbugs

Expand All @@ -27,6 +28,7 @@ minecraft-velocity-proxy = { module = "com.velocitypowered:velocity-proxy", vers
tool-commons-io = { module = "commons-io:commons-io", version.ref = "tool-commons-io" }
tool-fastutil = { module = "it.unimi.dsi:fastutil-core", version.ref = "tool-fastutil" }
tool-google-guava = { module = "com.google.guava:guava", version.ref = "tool-google-guava" }
tool-google-gson = { module = "com.google.code.gson:gson", version.ref = "tool-google-gson" }
tool-netty-codec = { module = "io.netty:netty-codec", version.ref = "tool-netty" }
tool-netty-handler = { module = "io.netty:netty-handler", version.ref = "tool-netty" }
tool-spotbugs-annotations = { module = "com.github.spotbugs:spotbugs-annotations", version.ref = "tool-spotbugs-annotations" }
Expand Down
17 changes: 17 additions & 0 deletions mapping/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# mapping module

This module generates `mapping/*.json` resources at build time using Java code.

## Main tasks

- `generateMappings`: downloads the Mojang version manifest and the required `server.jar` files, runs the data generator, and produces mapping resources.
- `mappingResourcesJar`: packages the generated `mapping/**` resources as a dedicated artifact consumed by the `plugin` module.

## Resource source

Seed and fallback files are stored in `src/main/seeds/mapping/`.

## Consumption

The `plugin` module consumes this module's resource artifact through the `mappingResourcesElements` configuration and merges it into the final plugin package during `processResources`.

83 changes: 83 additions & 0 deletions mapping/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
@file:Suppress("UnstableApiUsage")

import net.minecraftforge.licenser.LicenseExtension
import org.gradle.api.attributes.Usage
import org.gradle.api.tasks.JavaExec

plugins {
java
}

tasks.withType<JavaCompile> {
options.release.set(21)
options.encoding = "UTF-8"
}

dependencies {
implementation(libs.tool.commons.io)
implementation(libs.tool.google.guava)
implementation(libs.tool.google.gson)

compileOnly(libs.tool.spotbugs.annotations)
}

extensions.configure<LicenseExtension> {
setHeader(rootProject.file("HEADER.txt"))
}

val generatedMappingsDir = layout.buildDirectory.dir("generated/resources/mapping")
val minecraftCacheDir = layout.buildDirectory.dir("minecraft")
val seedsDir = layout.projectDirectory.dir("src/main/seeds")
val manifestUrl = providers.gradleProperty("manifestUrl")
val cacheValidMillis = providers.gradleProperty("cacheValidMillis")
val gameVersion = providers.gradleProperty("gameVersion")

val generateMappings by tasks.registering(JavaExec::class) {
group = LifecycleBasePlugin.BUILD_GROUP
description = "Generates Minecraft mapping resources for the plugin module."

dependsOn(tasks.named("compileJava"))

mainClass.set("net.elytrium.limboapi.mapping.MappingGeneratorMain")
classpath = sourceSets.main.get().runtimeClasspath

inputs.dir(seedsDir)
inputs.property("manifestUrl", manifestUrl)
inputs.property("cacheValidMillis", cacheValidMillis)
inputs.property("gameVersion", gameVersion)
inputs.property("cacheRefreshBucket", cacheValidMillis.map { System.currentTimeMillis() / it.toLong() })
outputs.dir(generatedMappingsDir)

doFirst {
args = listOf(
generatedMappingsDir.get().asFile.absolutePath,
minecraftCacheDir.get().asFile.absolutePath,
seedsDir.asFile.absolutePath,
manifestUrl.get(),
cacheValidMillis.get(),
)
}
}

val mappingResourcesJar by tasks.registering(Jar::class) {
group = LifecycleBasePlugin.BUILD_GROUP
description = "Packages generated mapping resources for consumption by the plugin module."

archiveClassifier.set("resources")
dependsOn(generateMappings)
from(generatedMappingsDir)
}

val mappingResourcesElements by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false

attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
}
}

artifacts {
add(mappingResourcesElements.name, mappingResourcesJar)
}

Loading