Class GenerateLegacyInheritedMappingsTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
net.fabricmc.loom.pipeline.GenerateLegacyInheritedMappingsTask
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

@CacheableTask public abstract class GenerateLegacyInheritedMappingsTask extends org.gradle.api.DefaultTask
为 1.12.2 的 tiny 映射补全「实现类缺失的继承方法条目」.

要解决什么

1.12.2 的 MCP 映射只给「声明该方法的类」记录条目,子类里 override 的方法不再重复登记。 例如 ShapedRecipes implements IRecipe:IRecipe 有 b()Laip; -> getRecipeOutput,而 ShapedRecipes 自身也声明了同签名方法却没有条目。

ForgeGradle 用的 SpecialSource 有 fallbackInheritanceProvider:查不到就沿继承链往上找, 所以能补出名字。loom 用的 TinyRemapper 没有这个回退机制——成员映射按 (声明类, 名称, 描述符) 精确匹配,查不到就保持原名。于是 ShapedRecipes.b() 不会被改成 getRecipeOutput(),下游 RecipesMapExtending 继承不到实现, 运行期抛 AbstractMethodError: getRecipeOutput is abstract。

本任务把「SpecialSource 会往上找出来的结果」提前算好、显式写进映射,让 TinyRemapper 一查即中。

为什么是独立任务而不是配置期计算

补全需要读 class 的继承关系,且要产出约 5900 条新映射。 放在配置期会让每次 Gradle 启动都重跑一遍,配置阶段显著变慢,也会拖累配置缓存。 做成 CacheableTask:配置期只登记输入输出,执行期才计算,并可 up-to-date / 命中构建缓存。

补全要迭代到不动点

名字可能沿继承链隔层传播,单轮只看直接父类型会漏掉深层条目(1.12.2 实测单轮漏约 10%), 详见 GenerateLegacyInheritedMappingsTask.TinyMappings.addInheritedMethods(java.util.Map<java.lang.String, net.fabricmc.loom.pipeline.GenerateLegacyInheritedMappingsTask.ClassMeta>)。

产物形态

输出的 tiny 与输入**同格式**(tiny v2、同 namespace 列),只在缺失处追加方法行。 输入里已有的行原样保留,顺序不变——增量 diff 因此只体现新增部分。
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Named

    org.gradle.api.Named.Namer
  • Field Summary

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    abstract org.gradle.api.file.RegularFileProperty
    输入的 srg 命名空间 tiny(mappings-srg.tiny).
    abstract org.gradle.api.file.ConfigurableFileCollection
    原始 notch 命名空间的 Minecraft jar(可多个:client / server).
    abstract org.gradle.api.file.RegularFileProperty
    补全后的 tiny(与 getMappings() 同格式,追加缺失的继承方法行).

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Constructor Details

    • GenerateLegacyInheritedMappingsTask

      public GenerateLegacyInheritedMappingsTask()
  • Method Details

    • getMappings

      @InputFiles @PathSensitive(NONE) public abstract org.gradle.api.file.RegularFileProperty getMappings()
      输入的 srg 命名空间 tiny(mappings-srg.tiny).
    • getMinecraftJars

      @InputFiles @PathSensitive(NONE) public abstract org.gradle.api.file.ConfigurableFileCollection getMinecraftJars()
      原始 notch 命名空间的 Minecraft jar(可多个:client / server).

      只用于读取类继承关系与方法声明,不产出任何 class。

    • getOutputMappings

      @OutputFile public abstract org.gradle.api.file.RegularFileProperty getOutputMappings()
      补全后的 tiny(与 getMappings() 同格式,追加缺失的继承方法行).
    • generate

      public void generate() throws IOException
      Throws:
      IOException