Class GenerateMixinMappingsTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
net.fabricmc.loom.pipeline.GenerateMixinMappingsTask
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 GenerateMixinMappingsTask extends org.gradle.api.DefaultTask
L3 流水线:生产 Mixin AP 用的 mappings-mixin-<namespace>.tiny.

它取代的是 MappingConfiguration.getReplacedTarget 里那段配置期同步执行的 「读平台映射文件首行 → 把两个命名空间名字互换 → 原子落位」。

为什么需要搬出来

Mixin AP 是 javac 的注解处理器,它通过 -AinMapFileNamed<Ns>=<绝对路径> 参数接收映射文件。参数必须在编译任务启动前就定好,于是那个路径必须在配置期可得—— 这正是 getReplacedTarget 被放在配置期、进而把整个 mappings 迁移拖在配置期的原因。

改为任务产出后,路径仍是同一个(<userCache>/<mappingsIdentifier>/mappings-mixin-<ns>.tiny), 但文件什么时候写出来交给任务图:编译任务依赖本任务,参数里给的路径在执行期已是就绪产物。

与配置期实现的一致性

首行改写规则、原子落位方式与配置期 writeReplacedTarget 逐字一致: intermediary → yraidemretni(先占位避免二次替换),再 <namespace> → intermediary。 因此产物字节不变。
  • 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.provider.Property<String>
    refmap 的目标命名空间,决定改写后的首行写什么.
    abstract org.gradle.api.file.RegularFileProperty
    产物:mappings-mixin-<namespace>.tiny.
    abstract org.gradle.api.file.RegularFileProperty
    平台映射文件(未改写的原始 tiny);它由 mappings 阶段(或迁移任务)产出.
    void
    run()
     

    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

  • Constructor Details

    • GenerateMixinMappingsTask

      public GenerateMixinMappingsTask()
  • Method Details

    • getPlatformMappings

      @InputFile @PathSensitive(NONE) public abstract org.gradle.api.file.RegularFileProperty getPlatformMappings()
      平台映射文件(未改写的原始 tiny);它由 mappings 阶段(或迁移任务)产出.
    • getNamespace

      @Input public abstract org.gradle.api.provider.Property<String> getNamespace()
      refmap 的目标命名空间,决定改写后的首行写什么.
    • getOutputMappings

      @OutputFile public abstract org.gradle.api.file.RegularFileProperty getOutputMappings()
      产物:mappings-mixin-<namespace>.tiny.
    • run

      public void run() throws IOException
      Throws:
      IOException