Class LibraryJson

java.lang.Object
com.cleanroommc.gradle.api.util.dist.LibraryJson

public final class LibraryJson extends Object
Turns resolved artifacts into the library entries launchers understand.

The MMC pack and the installer profile are two dialects of the same JSON. MMC writes the overlay on top of Minecraft 1.12.2, whereas the installer list is self-contained.

  • Method Details

    • resolve

      public static List<Artifact> resolve(Artifact universal, List<? extends LibraryArtifact> libraries)
    • resolve

      public static List<Artifact> resolve(Artifact universal, List<? extends LibraryArtifact> libraries, Set<String> inherited)
      Resolves a component's libraries with the Cleanroom universal artifact included.
      Parameters:
      universal - the universal artifact the component publishes
      libraries - the component's declared libraries
      inherited - coordinates the parent component already supplies, which are skipped
    • resolve

      public static List<Artifact> resolve(List<? extends LibraryArtifact> libraries, Set<String> inherited)
      Resolves a component's libraries without adding the Cleanroom universal artifact.
      Parameters:
      libraries - the component's declared libraries
      inherited - coordinates a parent component already supplies, which are skipped
    • mmcLibraries

      public static com.google.gson.JsonArray mmcLibraries(List<Artifact> artifacts)
      The MultiMC/Prism dialect: Natives are folded into their base module under classifiers with a natives platform map.
      Parameters:
      artifacts - the resolved artifacts to write
    • mojangLibraries

      public static com.google.gson.JsonArray mojangLibraries(List<Artifact> artifacts)
      The Mojang dialect used by version.json for classpath libraries: One flat entry per artifact, classifiers in the name, including side-less native jars such as Netty's.
      Parameters:
      artifacts - the resolved artifacts to write
    • mojangNativeLibraries

      public static com.google.gson.JsonArray mojangNativeLibraries(List<Artifact> artifacts)
      The Mojang dialect for natives: One entry per classifier with a platform rule, extracted rather than classpathed. Separate entries are required because the published classifier names do not share a usable ${arch} template.
      Parameters:
      artifacts - the resolved native artifacts to write
    • embeddedLibrary

      public static com.google.gson.JsonObject embeddedLibrary(Artifact artifact)
      A library entry whose file the installer embeds rather than downloads.
      Parameters:
      artifact - the artifact the entry describes
    • ordinaryLibrary

      public static com.google.gson.JsonObject ordinaryLibrary(Artifact artifact)
    • localLibrary

      public static com.google.gson.JsonObject localLibrary(Artifact artifact)
      A library both MultiMC and Prism take from the instance's own libraries/ folder instead of downloading. The launcher matches it by bare file name, and never issues a download for it, so the entry carries no url.
      Parameters:
      artifact - the artifact the entry describes
    • isLocal

      public static boolean isLocal(Artifact artifact)
      An artifact with no download url is one whose file travels inside the archive.
      Parameters:
      artifact - the artifact to test
    • isLocalRepository

      public static boolean isLocalRepository(String url)
    • download

      public static com.google.gson.JsonObject download(Artifact artifact, boolean withPath)
      The download block an artifact's entry carries.
      Parameters:
      artifact - the artifact the block describes
      withPath - whether to include the path key, which Mojang's format carries but not MMC's format
    • artifact

      public static Artifact artifact(Coordinate coordinate, Path path, String url)
    • nativePlatform

      public static String nativePlatform(String classifier)
    • isNative

      public static boolean isNative(Coordinate coordinate)
    • trailingSlash

      public static String trailingSlash(String value)