Skip to content

Conversation

@LexManos
Copy link
Member

First pass at making a gradle plugin.
This is functional. See the demo for the examples.
Need to speak with @Jonathing about a lot of the implementation.

I did not use ToolExecBase because I have a few issues with it.
Namely, the Tool object is very clunky to work with.
It doesn't auto-detect main classes.
It doesn't support maven coordinates, or downloading the tools from configured repositories.

My implementation in theory (gradle didn't yell at me) is compatible with the config cache.
It uses detached configurations to download the mappings and tool.

So a basic overview:

plugins {
  id 'net.minecraftforge.renamer'
}

renamer {
  mappings(channel, version) // Shorthand for mappings('net.minecraft:mappings_channel:version@tsrg.gz')
  mappings(string) // Shorthand for mappings(dependencies.create(string))
  mappings(Dependency) // Will use this dependency as the mapping file for subsequent calls to renamer.rename(task)
}

// Creates a 'jarRename' task using the compileClasspath
// input is set to task.archiveFile
// output is set to a renamed task.archiveFile (adding -renamed before the extension)
// map is set from the previous call to renamer.mappings (or null if unset)
// tool is set to `net.minecraftforge:ForgeAutoRenamingTool:1.1.2:all`
// args is set to "--input", "{input}", "--output", "{output}", "--map", "{map}", "--lib={library}"
// javaLauncher is set to javaToolchains.launcherFor(java.toolchain)
// Shorthand for renamer.rename(jar, jar.name + 'Rename', null)
renamer.rename(jar)

// It also support specifying a closure
renamer.rename(jar) {
  map = file('map.tsrg')
}

// Or configuring the task itself
tasks.named('jarRename') {
  map = file('map.tsrg')
}

I have not done anything to mark the task as an artifact/publish.

@LexManos LexManos marked this pull request as draft December 13, 2025 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant