Record Class EnvironmentSpec

java.lang.Object
java.lang.Record
net.fabricmc.loom.spec.EnvironmentSpec
All Implemented Interfaces:
Serializable

public record EnvironmentSpec(String minecraftVersion, MinecraftVersionMeta versionMeta, EnvironmentSpec.LoaderSpec loader, EnvironmentSpec.MappingDefinition mappings, List<EnvironmentSpec.PipelineStep> pipeline) extends Record implements Serializable
环境规格:配置期唯一被读的「小数据」.

本类型是把环境供给从配置期搬到执行期的**接缝**。当前配置期存在的环是:

   配置本项目 → 需要 mapped MC jar(mod 重映射的 classpath)
              → jar 需任务产出 → 任务需所有项目配置完成 → 回到起点
 

破环的办法不是「让配置期更快地生产 jar」,而是把「依赖图需要的」与「产物需要的」分开: 前者只需要**配方**,后者才是重活。本类型承载前者。

为什么 mappings 是配方而不是产物

mappings 描述「用哪套基础映射、什么迁移规则、目标命名空间」,而不是算好的映射文件。 所以它不需要任何产物存在就能构造——这正是环被切断的地方。

不可序列化的部分

versionMeta 是已解析的版本元数据对象。它由版本清单与 minecraft_info.json 派生,二者都通过 SpecStore 按内容身份缓存,因此重复构造的成本是一次 JSON 反序列化, 而不是「网络 + 全文解析」。这也是本类型可以安全地被配置缓存序列化的前提。

边界

本类型**不含**产物路径、不含任务引用、不含 Project。产物由 L3 流水线的任务声明, 通过 Provider 接线给下游,配置期不触碰文件系统。
See Also:
  • Constructor Details

    • EnvironmentSpec

      public EnvironmentSpec(String minecraftVersion, MinecraftVersionMeta versionMeta, EnvironmentSpec.LoaderSpec loader, EnvironmentSpec.MappingDefinition mappings, List<EnvironmentSpec.PipelineStep> pipeline)
      Creates an instance of a EnvironmentSpec record class.
      Parameters:
      minecraftVersion - the value for the minecraftVersion record component
      versionMeta - the value for the versionMeta record component
      loader - the value for the loader record component
      mappings - the value for the mappings record component
      pipeline - the value for the pipeline record component
  • Method Details

    • needsMappingMigration

      public boolean needsMappingMigration()
      Returns 该平台是否需要在重映射之前先做映射迁移..

      Forge 系的最终映射依赖「打补丁后的中间产物」,因此迁移是一个独立的流水线节点, 它的输入是 EnvironmentSpec.PipelineStep.APPLY_LOADER_PATCHES 的输出——这是 DAG,不是环。

      Returns:
      该平台是否需要在重映射之前先做映射迁移
    • finalJarStep

      public Optional<EnvironmentSpec.PipelineStep> finalJarStep()
      Returns 流水线中最后一个产出可被依赖的 jar 的步骤..

      供 L1 接线时判断「应当把哪个步骤的输出挂进 configuration」。

      Returns:
      流水线中最后一个产出可被依赖的 jar 的步骤
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • minecraftVersion

      public String minecraftVersion()
      Returns the value of the minecraftVersion record component.
      Returns:
      the value of the minecraftVersion record component
    • versionMeta

      public MinecraftVersionMeta versionMeta()
      Returns the value of the versionMeta record component.
      Returns:
      the value of the versionMeta record component
    • loader

      public EnvironmentSpec.LoaderSpec loader()
      Returns the value of the loader record component.
      Returns:
      the value of the loader record component
    • mappings

      Returns the value of the mappings record component.
      Returns:
      the value of the mappings record component
    • pipeline

      public List<EnvironmentSpec.PipelineStep> pipeline()
      Returns the value of the pipeline record component.
      Returns:
      the value of the pipeline record component