Record Class LocalMavenHelper

java.lang.Object
java.lang.Record
net.fabricmc.loom.configuration.mods.dependency.LocalMavenHelper

public record LocalMavenHelper(String group, String name, String version, @Nullable String baseClassifier, Path root, @Nullable String snapshotVersion) extends Record
  • Constructor Details

    • LocalMavenHelper

      public LocalMavenHelper(String group, String name, String version, @Nullable String baseClassifier, Path root)
    • LocalMavenHelper

      public LocalMavenHelper(String group, String name, String version, @Nullable String baseClassifier, Path root, @Nullable String snapshotVersion)
      Creates an instance of a LocalMavenHelper record class.
      Parameters:
      group - the value for the group record component
      name - the value for the name record component
      version - the value for the version record component
      baseClassifier - the value for the baseClassifier record component
      root - the value for the root record component
      snapshotVersion - the value for the snapshotVersion record component
  • Method Details

    • copyToMaven

      public Path copyToMaven(Path artifact, @Nullable String classifier) throws IOException
      Throws:
      IOException
    • exists

      public boolean exists(String classifier)
      Returns 该 maven 构件的 jar 与 pom 是否都存在..

      只做存在性判定,不校验内容,语义保持不变。若调用点需要的是「内容可用」——典型场景是把产物 当作跨 daemon/跨 loom 版本共享缓存里的就绪判据——请改用 isReusable(String)。

      Returns:
      该 maven 构件的 jar 与 pom 是否都存在
    • isReusable

      public boolean isReusable(@Nullable String classifier)
      Returns 该 maven 构件是否既存在、内容又可复用..

      在 exists(String) 之上追加 jar 的内容校验(见 JarReusability.isReusable(Path)): 这些仓库目录跨 daemon、跨 loom 版本共享,旧版本 loom 以最终路径为输出就地写, 被中断会留下 0 字节或截断的 jar;只判存在会让这类残骸被当成暖缓存,作为 Gradle 依赖进入编译链。

      该口径不会把正常产物判为不可用——按「临时文件 + 原子落位」发布的 jar 必然可打开且非空—— 因此不会引起「每次构建都重建」。

      Returns:
      该 maven 构件是否既存在、内容又可复用
    • getNotation

      public String getNotation()
    • savePom

      public void savePom()
    • getOutputFile

      public Path getOutputFile(@Nullable String classifier)
    • getRelativeArtifactPath

      public String getRelativeArtifactPath(@Nullable String classifier)
      产出文件相对于仓库根的路径(以 / 分隔).

      供文件依赖构造使用:任务持有产出根目录,消费方据此换算出文件依赖, 从而获得携带任务依赖的引用(见架构 §5.1.1)。

    • withClassifier

      public LocalMavenHelper withClassifier(String classifier)
    • 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.
    • group

      public String group()
      Returns the value of the group record component.
      Returns:
      the value of the group record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • version

      public String version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • baseClassifier

      public @Nullable String baseClassifier()
      Returns the value of the baseClassifier record component.
      Returns:
      the value of the baseClassifier record component
    • root

      public Path root()
      Returns the value of the root record component.
      Returns:
      the value of the root record component
    • snapshotVersion

      public @Nullable String snapshotVersion()
      Returns the value of the snapshotVersion record component.
      Returns:
      the value of the snapshotVersion record component