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, Map<String,String> repositories)
      Resolves the library inputs into a deterministic, deduplicated artifact list.
      Parameters:
      universal - the loader's own jar, always listed first
      repositories - group prefix to base URL, with * as the fallback
    • resolve

      public static List<Artifact> resolve(Artifact universal, List<? extends LibraryArtifact> libraries, Set<String> inherited, Map<String,String> repositories)
      Parameters:
      inherited - coordinates the 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.
    • 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 LWJGL 3 native jars.
    • mojangNativeLibraries

      public static com.google.gson.JsonArray mojangNativeLibraries(List<Artifact> artifacts)
      The Mojang dialect for natives: One entry per module, its classifiers under a natives platform map, extracted rather than classpathed.
    • embeddedLibrary

      public static com.google.gson.JsonObject embeddedLibrary(Artifact artifact)
      A library entry whose file the installer embeds rather than downloads.
    • 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.
    • isLocal

      public static boolean isLocal(Artifact artifact)
      An artifact with no download url is one whose file travels inside the archive.
    • nativeLibrary

      public static com.google.gson.JsonObject nativeLibrary(Coordinate base, List<Artifact> artifacts)
    • download

      public static com.google.gson.JsonObject download(Artifact artifact, boolean withPath)
      Parameters:
      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)
    • artifactUrl

      public static String artifactUrl(Coordinate coordinate, Map<String,String> repositories)
      Longest matching group prefix wins with * being the fallback.
    • nativePlatform

      public static String nativePlatform(String classifier)
    • isNative

      public static boolean isNative(Coordinate coordinate)
    • trailingSlash

      public static String trailingSlash(String value)