Class ManipulateForgeMappingsTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
net.fabricmc.loom.pipeline.ManipulateForgeMappingsTask
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 ManipulateForgeMappingsTask extends org.gradle.api.DefaultTask
L3 流水线:生产 Forge 的「迁移后 mappings」(mappings-migrated.tiny 与 mappings-srg-migrated.tiny / mappings-mojang-migrated.tiny).

它取代的是 ForgeMigratedMappingConfiguration.manipulateMappings 里那段配置期同步执行的 「复制原始 mappings → 跑两个迁移器改写 → 原子落位 → 发布就绪标记」。

旧路径 vs 本任务
旧路径本任务
是否需要重建配置期 isOutdated 判定(就绪标记的 hash 比对) Gradle up-to-date 检查(输入内容 + 输出快照)
并发保护跨进程文件锁 + 锁内二次确认任务图 + 构建缓存
残骸恢复标记先失效、产物全部落位后才发布输出快照不符即重建
执行时机配置期(setupPost)执行期

生产逻辑不在这里

真正的生产由 ForgeMigratedMappingConfiguration.manipulate(dev.architectury.loom.forge.MappingsMigrator.Inputs, java.nio.file.Path, java.nio.file.Path, java.nio.file.Path, java.nio.file.Path, java.lang.String, java.util.function.Consumer<java.lang.String>) 持有:配置期回退路径与执行期任务 共用同一份实现(复制顺序、迁移器调用顺序、原子落位与就绪标记内容都一致),因此两条路径的产物逐字节一致。 本任务另写一套「等价」的实现就会引入分叉——同一个输入产出两份略有差异的 mappings, 而且这种差异不会让任何一方失败,只会静默地换一套映射。

为什么输入里有 patched 中间产物

两个迁移器(FieldMappingsMigrator / MethodInheritanceMappingsMigrator)在各自缓存 未命中时要按路径读 patched 中间 jar。这正是本步要消灭的那条「配置期按路径读执行期产物」依赖: 那件产物由 generateForgePatchedIntermediateJar 产出,配置期读不到。改为任务输入之后, 依赖由任务图表达,缓存未命中也不再需要整批回退到配置期。

为什么就绪标记也是输出

mappings-migrated.hash 位于跨 daemon、跨工作树共享的缓存目录:另一棵工作树若仍在跑改造前的 loom,会读它判断「迁移产物是否与当前输入同代」。因此本任务照旧写出它,内容与配置期路径逐字一致 (同一份实现算出的哈希)。它只是兼容性产物,不参与本任务自己的 up-to-date 判定之外的任何逻辑。
  • Nested Class Summary

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    任务名:消费侧(本仓库的测试与诊断)按它引用产出任务.

    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
    abstract org.gradle.api.file.RegularFileProperty
    Forge 的 universal jar:MethodInheritanceMappingsMigrator 的继承关系来源之一.
    abstract org.gradle.api.file.RegularFileProperty
    Forge 的 userdev jar:同上.
    abstract org.gradle.api.provider.Property<Boolean>
    本配置是否为 NeoForge(同上,mojang 命名空间).
    abstract org.gradle.api.provider.Property<Boolean>
    本配置是否生成 srg 命名空间的映射(决定读哪一份 patched 中间产物的命名空间).
    abstract org.gradle.api.file.RegularFileProperty
    产物:迁移后的默认映射树(mappings-migrated.tiny,与旧路径同一条路径).
    abstract org.gradle.api.file.RegularFileProperty
    产物:迁移后的命名空间映射树(mappings-srg-migrated.tiny / mappings-mojang-migrated.tiny).
    abstract org.gradle.api.provider.Property<String>
    迁移器缓存所在目录(共享的 forge 缓存目录);目录不存在时执行期创建.
    abstract org.gradle.api.file.RegularFileProperty
    打补丁后的中间 Minecraft jar:迁移器缓存未命中时读它的字段与继承关系.
    abstract org.gradle.api.provider.Property<String>
    平台 id:只用于日志文本(与旧路径的 :manipulated <platform> mappings in ... 逐字一致).
    abstract org.gradle.api.file.RegularFileProperty
    迁移前、未按命名空间合并的映射树(mappings.tiny).
    abstract org.gradle.api.file.RegularFileProperty
    迁移前、已按命名空间合并的映射树(mappings-srg.tiny / mappings-mojang.tiny).
    abstract org.gradle.api.file.RegularFileProperty
    产物:迁移产物的就绪标记(mappings-migrated.hash,内容与旧路径逐字一致).
    abstract org.gradle.api.provider.Property<Boolean>
    是否强制重建(对应 --refresh-dependencies):旧路径在该情形下无条件重跑迁移器.
    void
     

    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
  • Field Details

    • NAME

      public static final String NAME
      任务名:消费侧(本仓库的测试与诊断)按它引用产出任务.
      See Also:
  • Constructor Details

    • ManipulateForgeMappingsTask

      public ManipulateForgeMappingsTask()
  • Method Details

    • getRawMappings

      @InputFile @PathSensitive(NONE) public abstract org.gradle.api.file.RegularFileProperty getRawMappings()
      迁移前、未按命名空间合并的映射树(mappings.tiny).
    • getRawMappingsWithNs

      @InputFile @PathSensitive(NONE) public abstract org.gradle.api.file.RegularFileProperty getRawMappingsWithNs()
      迁移前、已按命名空间合并的映射树(mappings-srg.tiny / mappings-mojang.tiny).
    • getPatchedIntermediateJar

      @InputFile @PathSensitive(NONE) public abstract org.gradle.api.file.RegularFileProperty getPatchedIntermediateJar()
      打补丁后的中间 Minecraft jar:迁移器缓存未命中时读它的字段与继承关系.
    • getForgeJar

      @InputFile @PathSensitive(NONE) public abstract org.gradle.api.file.RegularFileProperty getForgeJar()
      Forge 的 universal jar:MethodInheritanceMappingsMigrator 的继承关系来源之一.
    • getForgeUserdevJar

      @InputFile @PathSensitive(NONE) public abstract org.gradle.api.file.RegularFileProperty getForgeUserdevJar()
      Forge 的 userdev jar:同上.
    • getMigratorCacheDir

      @Input public abstract org.gradle.api.provider.Property<String> getMigratorCacheDir()
      迁移器缓存所在目录(共享的 forge 缓存目录);目录不存在时执行期创建.
    • getHasSrg

      @Input public abstract org.gradle.api.provider.Property<Boolean> getHasSrg()
      本配置是否生成 srg 命名空间的映射(决定读哪一份 patched 中间产物的命名空间).
    • getHasMojang

      @Input public abstract org.gradle.api.provider.Property<Boolean> getHasMojang()
      本配置是否为 NeoForge(同上,mojang 命名空间).
    • getRefreshDeps

      @Input public abstract org.gradle.api.provider.Property<Boolean> getRefreshDeps()
      是否强制重建(对应 --refresh-dependencies):旧路径在该情形下无条件重跑迁移器.
    • getPlatformId

      @Input public abstract org.gradle.api.provider.Property<String> getPlatformId()
      平台 id:只用于日志文本(与旧路径的 :manipulated <platform> mappings in ... 逐字一致).
    • getMigratedMappings

      @OutputFile public abstract org.gradle.api.file.RegularFileProperty getMigratedMappings()
      产物:迁移后的默认映射树(mappings-migrated.tiny,与旧路径同一条路径).
    • getMigratedMappingsWithNs

      @OutputFile public abstract org.gradle.api.file.RegularFileProperty getMigratedMappingsWithNs()
      产物:迁移后的命名空间映射树(mappings-srg-migrated.tiny / mappings-mojang-migrated.tiny).
    • getReadyMarker

      @OutputFile public abstract org.gradle.api.file.RegularFileProperty getReadyMarker()
      产物:迁移产物的就绪标记(mappings-migrated.hash,内容与旧路径逐字一致).
    • manipulate

      public void manipulate() throws IOException
      Throws:
      IOException