Skip to content

Commit

Permalink
Don't include param mappings in mappings namespace names
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Dec 30, 2024
1 parent 787f10e commit c5b5c73
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ open class InitialTasks(

vanillaMappings.set(downloadMappings.flatMap { it.outputFile })

outputMappings.set(cache.resolve(MOJANG_YARN_MAPPINGS))
outputMappings.set(cache.resolve(MOJANG_MAPPINGS))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ open class SpigotTasks(

sourceMappings.set(generateMappings.flatMap { it.outputMappings })

outputMappings.set(cache.resolve(SPIGOT_MOJANG_YARN_MAPPINGS))
outputMappings.set(cache.resolve(SPIGOT_MOJANG_MAPPINGS))
notchToSpigotMappings.set(cache.resolve(OBF_SPIGOT_MAPPINGS))
spigotMemberMappings.set(cache.resolve(SPIGOT_MEMBER_MAPPINGS))
}
Expand All @@ -87,7 +87,7 @@ open class SpigotTasks(
libraries.from(extractFromBundler.map { it.serverLibraryJars.asFileTree })
inputMappings.set(generateSpigotMappings.flatMap { it.outputMappings })

outputMappings.set(cache.resolve(CLEANED_SPIGOT_MOJANG_YARN_MAPPINGS))
outputMappings.set(cache.resolve(CLEANED_SPIGOT_MOJANG_MAPPINGS))
}

val patchMappings by tasks.registering<PatchMappings> {
Expand All @@ -97,6 +97,6 @@ open class SpigotTasks(
fromNamespace.set(SPIGOT_NAMESPACE)
toNamespace.set(DEOBF_NAMESPACE)

outputMappings.set(cache.resolve(PATCHED_SPIGOT_MOJANG_YARN_MAPPINGS))
outputMappings.set(cache.resolve(PATCHED_SPIGOT_MOJANG_MAPPINGS))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fun Project.createBuildTasks(
}
}

val reobfJar by tasks.registering<RemapJarTiny> {
val reobfJar by tasks.registering<RemapJar> {
group = "build"
description = "Re-obfuscate the built jar to obf mappings"

Expand Down Expand Up @@ -102,5 +102,5 @@ fun Task.reobfRequiresDebug() {

data class ServerBuildTasks(
val includeMappings: TaskProvider<IncludeMappings>,
val reobfJar: TaskProvider<RemapJarTiny>,
val reobfJar: TaskProvider<RemapJar>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import org.cadixdev.lorenz.model.TopLevelClassMapping
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.jvm.toolchain.JavaLauncher
import org.gradle.kotlin.dsl.*
Expand All @@ -68,6 +69,7 @@ fun generateMappings(
vanillaMappingsPath: Path,
paramMappingsPath: Path?,
outputMappingsPath: Path,
deobfNamespaceString: String,
workerExecutor: WorkerExecutor,
launcher: JavaLauncher,
jvmArgs: List<String> = listOf("-Xmx1G")
Expand All @@ -83,6 +85,7 @@ fun generateMappings(
vanillaMappings.set(vanillaMappingsPath)
paramMappings.set(paramMappingsPath)
outputMappings.set(outputMappingsPath)
deobfNamespace.set(deobfNamespaceString)
}

return queue
Expand Down Expand Up @@ -129,6 +132,7 @@ abstract class GenerateMappings : JavaLauncherTask() {
vanillaMappings.path,
paramMappings.pathOrNull,
outputMappings.path,
DEOBF_NAMESPACE,
workerExecutor,
launcher.get(),
jvmargs.get()
Expand All @@ -141,6 +145,7 @@ abstract class GenerateMappings : JavaLauncherTask() {
val vanillaMappings: RegularFileProperty
val paramMappings: RegularFileProperty
val outputMappings: RegularFileProperty
val deobfNamespace: Property<String>
}

abstract class GenerateMappingsAction : WorkAction<GenerateMappingsParams> {
Expand Down Expand Up @@ -184,7 +189,7 @@ abstract class GenerateMappings : JavaLauncherTask() {
}

ensureParentExists(parameters.outputMappings)
MappingFormats.TINY.write(filledMerged, parameters.outputMappings.path, OBF_NAMESPACE, DEOBF_NAMESPACE)
MappingFormats.TINY.write(filledMerged, parameters.outputMappings.path, OBF_NAMESPACE, parameters.deobfNamespace.get())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.jvm.toolchain.JavaLauncher

abstract class RemapJarTiny : JavaLauncherTask() {
abstract class RemapJar : JavaLauncherTask() {

@get:Classpath
abstract val inputJar: RegularFileProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,25 @@ const val UPSTREAM_WORK_DIR_PROPERTY = "paperweightUpstreamWorkDir"
private const val JARS_PATH = "$PAPER_PATH/jars"
const val MINECRAFT_JARS_PATH = "$JARS_PATH/minecraft"
const val MINECRAFT_SOURCES_PATH = "$JARS_PATH/minecraft-sources"

const val PAPER_JARS_PATH = "$JARS_PATH/paper"
const val PAPER_SOURCES_JARS_PATH = "$JARS_PATH/paper-sources"

private const val MAPPINGS_DIR = "$PAPER_PATH/mappings"
const val SERVER_MAPPINGS = "$MAPPINGS_DIR/server_mappings.txt"
const val MOJANG_YARN_MAPPINGS = "$MAPPINGS_DIR/official-mojang+yarn.tiny"
const val MOJANG_MAPPINGS = "$MAPPINGS_DIR/official-mojang.tiny"

const val SPIGOT_MOJANG_YARN_MAPPINGS = "$MAPPINGS_DIR/spigot-mojang+yarn.tiny"
const val SPIGOT_MOJANG_MAPPINGS = "$MAPPINGS_DIR/spigot-mojang.tiny"
const val OBF_SPIGOT_MAPPINGS = "$MAPPINGS_DIR/official-spigot.tiny"
const val SPIGOT_MEMBER_MAPPINGS = "$MAPPINGS_DIR/spigot-members.csrg"
const val CLEANED_SPIGOT_MOJANG_YARN_MAPPINGS = "$MAPPINGS_DIR/spigot-mojang+yarn-cleaned.tiny"
const val PATCHED_SPIGOT_MOJANG_YARN_MAPPINGS = "$MAPPINGS_DIR/spigot-mojang+yarn-patched.tiny"
const val REOBF_MOJANG_SPIGOT_MAPPINGS = "$MAPPINGS_DIR/mojang+yarn-spigot-reobf.tiny"
const val PATCHED_REOBF_MOJANG_SPIGOT_MAPPINGS = "$MAPPINGS_DIR/mojang+yarn-spigot-reobf-patched.tiny"
const val RELOCATED_PATCHED_REOBF_MOJANG_SPIGOT_MAPPINGS = "$MAPPINGS_DIR/mojang+yarn-spigot-reobf-patched-relocated.tiny"
const val CLEANED_SPIGOT_MOJANG_MAPPINGS = "$MAPPINGS_DIR/spigot-mojang-cleaned.tiny"
const val PATCHED_SPIGOT_MOJANG_MAPPINGS = "$MAPPINGS_DIR/spigot-mojang-patched.tiny"
const val REOBF_MOJANG_SPIGOT_MAPPINGS = "$MAPPINGS_DIR/mojang-spigot-reobf.tiny"
const val PATCHED_REOBF_MOJANG_SPIGOT_MAPPINGS = "$MAPPINGS_DIR/mojang-spigot-reobf-patched.tiny"
const val RELOCATED_PATCHED_REOBF_MOJANG_SPIGOT_MAPPINGS = "$MAPPINGS_DIR/mojang-spigot-reobf-patched-relocated.tiny"

const val OBF_NAMESPACE = "official"
const val SPIGOT_NAMESPACE = "spigot"
const val DEOBF_NAMESPACE = "mojang+yarn"
const val NEW_DEOBF_NAMESPACE = "mojang+parchment"
const val LEGACY_DEOBF_NAMESPACE = "mojang+yarn"
const val DEOBF_NAMESPACE = "mojang"
const val MAPPINGS_NAMESPACE_MANIFEST_KEY = "paperweight-mappings-namespace"

private const val DATA_PATH = "$PAPER_PATH/data"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,14 @@ abstract class PaperweightUser : Plugin<Project> {

createConfigurations(target, target.provider { userdevSetup }, setupTask)

val reobfJar by target.tasks.registering<RemapJarTiny> {
val reobfJar by target.tasks.registering<RemapJar> {
group = GENERAL_TASK_GROUP
description = "Remap the compiled plugin jar to Spigot's obfuscated runtime names."

mappingsFile.set(setupTask.flatMap { it.reobfMappings })
remapClasspath.from(setupTask.flatMap { it.mappedServerJar })

fromNamespace.set(DEOBF_NAMESPACE)
toNamespace.set(SPIGOT_NAMESPACE)

remapper.from(project.configurations.named(PLUGIN_REMAPPER_CONFIG))
remapperArgs.set(target.provider { userdevSetup.pluginRemapArgs })
}

target.configurations.register(REOBF_CONFIG) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.gradle.kotlin.dsl.*
* Configures input/output for `reobfJar` and potentially changes classifiers of other jars.
*/
fun interface ReobfArtifactConfiguration {
fun configure(project: Project, reobfJar: TaskProvider<RemapJarTiny>)
fun configure(project: Project, reobfJar: TaskProvider<RemapJar>)

companion object {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import org.gradle.internal.logging.progress.ProgressLogger
import org.gradle.internal.logging.progress.ProgressLoggerFactory
import org.gradle.jvm.toolchain.JavaLauncher
import org.gradle.jvm.toolchain.JavaToolchainService
import org.gradle.kotlin.dsl.*
import org.gradle.workers.WorkerExecutor

interface SetupHandler {
Expand All @@ -59,10 +60,17 @@ interface SetupHandler {
fun extractReobfMappings(output: Path)

fun afterEvaluate(context: ConfigurationContext) {
context.project.tasks.named<RemapJar>("reobfJar") {
remapperArgs.convention(pluginRemapArgs)
fromNamespace.convention(deobfNamespace)
}
}

val minecraftVersion: String

val deobfNamespace: String
get() = DEOBF_NAMESPACE

val pluginRemapArgs: List<String>

val paramMappings: MavenDep?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ abstract class UserdevSetup : BuildService<UserdevSetup.Parameters>, SetupHandle
override val minecraftVersion: String
get() = setup.minecraftVersion

override val deobfNamespace: String
get() = setup.deobfNamespace

override val pluginRemapArgs: List<String>
get() = setup.pluginRemapArgs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import io.papermc.paperweight.userdev.internal.action.Output
import io.papermc.paperweight.userdev.internal.action.Value
import io.papermc.paperweight.userdev.internal.action.WorkDispatcher
import io.papermc.paperweight.userdev.internal.util.jars
import io.papermc.paperweight.util.constants.*
import org.gradle.jvm.toolchain.JavaLauncher
import org.gradle.workers.WorkerExecutor

Expand All @@ -50,6 +51,7 @@ class GenerateMappingsAction(
vanillaMappingsPath = serverMappings.get(),
paramMappingsPath = paramMappings.get().singleFile.toPath(),
outputMappingsPath = outputMappings.get(),
deobfNamespaceString = LEGACY_DEOBF_NAMESPACE,
workerExecutor = workerExecutor,
launcher = javaLauncher.get()
).await()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RemapMinecraftAction(
inputJar = filteredVanillaJar.get(),
mappingsFile = mappings.get(),
fromNamespace = OBF_NAMESPACE,
toNamespace = DEOBF_NAMESPACE,
toNamespace = LEGACY_DEOBF_NAMESPACE,
remapClasspath = minecraftLibraryJars.get().jars(),
remapper = remapper.get(),
outputJar = outputJar.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ class SetupHandlerImplV2(
override val minecraftVersion: String
get() = bundle.config.minecraftVersion

override val deobfNamespace: String
get() = LEGACY_DEOBF_NAMESPACE

override val pluginRemapArgs: List<String>
get() = TinyRemapper.pluginRemapArgs // plugin remap args were not included in v2 bundles, if these change check this

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import io.papermc.paperweight.userdev.internal.setup.SetupHandler
import io.papermc.paperweight.userdev.internal.setup.UserdevSetup
import io.papermc.paperweight.userdev.internal.setup.action.*
import io.papermc.paperweight.util.*
import io.papermc.paperweight.util.constants.*
import java.nio.file.Path
import kotlin.io.path.*
import org.gradle.api.artifacts.DependencySet
Expand Down Expand Up @@ -271,6 +272,9 @@ class SetupHandlerImplV5(
override val minecraftVersion: String
get() = bundle.config.minecraftVersion

override val deobfNamespace: String
get() = LEGACY_DEOBF_NAMESPACE

override val pluginRemapArgs: List<String>
get() = bundle.config.buildData.pluginRemapArgs

Expand Down

0 comments on commit c5b5c73

Please sign in to comment.