Class Utilities
java.lang.Object
com.gtnewhorizons.retrofuturagradle.util.Utilities
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final recordstatic classProvides patching context from an in-memory jarstatic final recordstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.opencsv.CSVReadercreateCsvReader(File file) static com.opencsv.CSVReadercreateCsvReader(URL url) static voiddecompressArchive(String archiveType, Path archivePath, Path destination) static voiddecompressArchive(org.apache.commons.compress.archivers.ArchiveInputStream<?> stream, Path destination) static byte[]emitClassBytes(org.objectweb.asm.tree.ClassNode node, int writerFlags) static URL[]filesToURLArray(Collection<File> cpFiles) static StringfixWindowsProcessCmdline(String cmdlineArg) A workaround for https://github.com/gradle/gradle/issues/6072static FilegetCacheDir(Project project, String... paths) static FilegetCacheRoot(Gradle gradle) static FilegetCacheRoot(Project project) static byte[]getClassBytes(Class<?> klass) static StringgetMapStringOrBlank(Map<?, ?> map, String key) static Stringstatic FilegetRawCacheDir(Project project, String... paths) static FilegetRawCacheRoot(Gradle gradle) static FilegetRawCacheRoot(Project project) static Utilities.MappingsSetloadMappingCsvs(File methodsCsv, File fieldsCsv, File paramsCsv, Collection<File> extraParamsCsvs, String genericsFilename) static voidLoad a JAR file into in-memory hashmapsstatic voidloadSrgMcpMappings(net.fabricmc.mappingio.tree.VisitableMappingTree srgMcp, net.fabricmc.mappingio.tree.VisitableMappingTree notchSrg, File methodsCsv, File fieldsCsv, File paramsCsv, Collection<File> extraParamsCsvs) static org.objectweb.asm.tree.ClassNodeparseClassBytes(byte[] bytes, String debugName) static Stringstatic byte[]readZipEntry(ZipFile jar, ZipEntry entry) static UUIDresolveUUID(String username, Gradle gradle) static FilesaveMemoryJar(Map<String, byte[]> loadedResources, Map<String, String> loadedSources, File target, boolean isTemporary) static byte[]simpleRemapClass(byte[] classBytes, Map<String, String> mappings)
-
Field Details
-
GSON
public static final com.google.gson.Gson GSON -
RFG_CACHE_SUBDIRECTORY
- See Also:
-
-
Constructor Details
-
Utilities
public Utilities()
-
-
Method Details
-
fixWindowsProcessCmdline
-
getRawCacheRoot
-
getRawCacheRoot
-
getCacheRoot
-
getCacheRoot
-
getRawCacheDir
-
getCacheDir
-
getMapStringOrBlank
-
getModuleSpecFromCachePath
- 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
- Throws:
IOException
-
createCsvReader
- Throws:
IOException
-
readZipEntry
- Throws:
IOException
-
getClassBytes
-
parseClassBytes
-
emitClassBytes
public static byte[] emitClassBytes(org.objectweb.asm.tree.ClassNode node, int writerFlags) -
readEmbeddedResourceText
-
loadMemoryJar
public static void loadMemoryJar(File jar, Map<String, byte[]> loadedResources, Map<String, throws IOExceptionString> loadedSources) Load a JAR file into in-memory hashmaps- Parameters:
jar- The JAR to loadloadedResources- The map to populate with non-java file contentsloadedSources- 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, throws IOExceptionString> loadedSources, File target, boolean isTemporary) - Throws:
IOException
-
decompressArchive
public static void decompressArchive(org.apache.commons.compress.archivers.ArchiveInputStream<?> stream, Path destination) throws IOException - Throws:
IOException
-
decompressArchive
-
filesToURLArray
- 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
- Parameters:
classBytes- The .class bytes to remapmappings- 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
-