Class Utilities

java.lang.Object
com.gtnewhorizons.retrofuturagradle.util.Utilities

public final class Utilities extends Object
  • Field Details

    • GSON

      public static final com.google.gson.Gson GSON
    • RFG_CACHE_SUBDIRECTORY

      public static final String RFG_CACHE_SUBDIRECTORY
      See Also:
  • Constructor Details

    • Utilities

      public Utilities()
  • Method Details

    • fixWindowsProcessCmdline

      public static String fixWindowsProcessCmdline(String cmdlineArg)
      A workaround for https://github.com/gradle/gradle/issues/6072
    • getRawCacheRoot

      public static File getRawCacheRoot(Project project)
    • getRawCacheRoot

      public static File getRawCacheRoot(Gradle gradle)
    • getCacheRoot

      public static File getCacheRoot(Gradle gradle)
    • getCacheRoot

      public static File getCacheRoot(Project project)
    • getRawCacheDir

      public static File getRawCacheDir(Project project, String... paths)
    • getCacheDir

      public static File getCacheDir(Project project, String... paths)
    • getMapStringOrBlank

      public static String getMapStringOrBlank(Map<?,?> map, String key)
    • getModuleSpecFromCachePath

      public static String getModuleSpecFromCachePath(Path path)
      Parameters:
      path - A path like "/home/user/.gradle/caches/modules-2/files-2.1/com.github.GTNewHorizons/CodeChickenLib/1.1.6/51081c1c2d8d75ae26f64427849de2c0ba99144/CodeChickenLib-1.1.6-dev.jar"
      Returns:
      A dependency specifier like "com.github.GTNewHorizons:CodeChickenLib:1.1.6:dev" or null if not a modules-2 path.
    • createCsvReader

      public static com.opencsv.CSVReader createCsvReader(URL url) throws IOException
      Throws:
      IOException
    • createCsvReader

      public static com.opencsv.CSVReader createCsvReader(File file) throws IOException
      Throws:
      IOException
    • readZipEntry

      public static byte[] readZipEntry(ZipFile jar, ZipEntry entry) throws IOException
      Throws:
      IOException
    • getClassBytes

      public static byte[] getClassBytes(Class<?> klass)
    • parseClassBytes

      public static org.objectweb.asm.tree.ClassNode parseClassBytes(byte[] bytes, String debugName)
    • emitClassBytes

      public static byte[] emitClassBytes(org.objectweb.asm.tree.ClassNode node, int writerFlags)
    • readEmbeddedResourceText

      public static String readEmbeddedResourceText(String path)
    • loadMemoryJar

      public static void loadMemoryJar(File jar, Map<String,byte[]> loadedResources, Map<String,String> loadedSources) throws IOException
      Load a JAR file into in-memory hashmaps
      Parameters:
      jar - The JAR to load
      loadedResources - The map to populate with non-java file contents
      loadedSources - The map to populate with java file contents
      Throws:
      IOException - Forwarded IO errors from the JAR reading process
    • saveMemoryJar

      public static File saveMemoryJar(Map<String,byte[]> loadedResources, Map<String,String> loadedSources, File target, boolean isTemporary) throws IOException
      Throws:
      IOException
    • decompressArchive

      public static void decompressArchive(org.apache.commons.compress.archivers.ArchiveInputStream<?> stream, Path destination) throws IOException
      Throws:
      IOException
    • decompressArchive

      public static void decompressArchive(String archiveType, Path archivePath, Path destination)
      Parameters:
      archiveType - One of ArchiveStreamFactory archive types
      archivePath - Path to the archive
      destination - Destination directory to extract to
    • filesToURLArray

      public static URL[] filesToURLArray(Collection<File> cpFiles) throws MalformedURLException
      Throws:
      MalformedURLException
    • loadMappingCsvs

      public static Utilities.MappingsSet loadMappingCsvs(File methodsCsv, File fieldsCsv, @Nullable File paramsCsv, @Nullable Collection<File> extraParamsCsvs, @Nullable String genericsFilename)
    • loadSrgMcpMappings

      public static void loadSrgMcpMappings(net.fabricmc.mappingio.tree.VisitableMappingTree srgMcp, net.fabricmc.mappingio.tree.VisitableMappingTree notchSrg, File methodsCsv, File fieldsCsv, @Nullable File paramsCsv, @Nullable Collection<File> extraParamsCsvs) throws IOException
      Throws:
      IOException
    • simpleRemapClass

      public static byte[] simpleRemapClass(byte[] classBytes, Map<String,String> mappings)
      Parameters:
      classBytes - The .class bytes to remap
      mappings - The combined mappings set to use for renaming items
      Returns:
      A jar with names remapped using simple find-and-replace on SRG names in the given mappings (no inheritance checks performed)
    • resolveUUID

      public static UUID resolveUUID(String username, Gradle gradle)