Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to use ForgeGradle's updateMappings task

What is it

This task will migrate (remap) the project's source files to a new mapping version.


Running this task with edit your project's source files. It does NOT make a backup. It is highly recommened that you commit any pending changes before doing this. (If you are not using version control, you should be.)

Before running the command

Source must be compilable

This process uses Srg2Source to remap the project's source files. Therefore, your project must be compilable for this process to work.

Adding other source sets

By default, the updateMappings task will only update the source directories in the projects main source set. If you use additioanl source sets in your project, then you must add them to the remapping tasks. Below is an example adding an api source set. Note: The property check is important as these tasks do not exists unless it is specified.

if (project.hasProperty('UPDATE_MAPPINGS')) {
   extractRangeMap {
   applyRangeMap {
   } { extractMappedNew.addTarget it }

The command

This command should be run before you update the mapping version in you build file.

./gradlew -PUPDATE_MAPPINGS="new mapping version" -PUPDATE_MAPPINGS_CHANNEL="snapshot" updateMappings

Note that the UPDATE_MAPPINGS_CHANNEL property is not required and will default to snapshot.

Known issues

  • Extra imports: Srg2Source is not the greatest with inner classes and will sometimes add extra imports for them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment