Skip to content

Add helper methods to access files inside zip files - #1081

Draft
LexManos wants to merge 1 commit into
MinecraftForge:FG_7.0from
LexManos:mapZips
Draft

Add helper methods to access files inside zip files#1081
LexManos wants to merge 1 commit into
MinecraftForge:FG_7.0from
LexManos:mapZips

Conversation

@LexManos

@LexManos LexManos commented Aug 7, 2026

Copy link
Copy Markdown
Member

This is a first draft of what I had in mind for addressing #1080
This just adds helper methods for converting a FileCollection of archives, to a FileCollection of files from those archives.

Example usages (untested, but should work):

configurations {
  mods
  implementation.extendsFrom mods
}

dependencies {
  mods renamer.dependency(libs.modA)
  mods renamer.dependency(libs.modB)

  implementation minecraft.dependency(forge) {
    facades.from('src/main/resources/META-INF/facades.cfg')
    facades.from(fg.mapFacades(configurations.mods))
    accessTransformers.from('src/main/resources/META-INF/at.cfg')
    accessTransformers.from(fg.mapAccessTransformers(configurations.mods))
  }
}

Its fairly generic, so you can do something like this:

configurations {
    sharedLibs
}

dependencies {
    sharedLibs 'org.json:json:20260719'
}
fg.mapZip(configurations.sharedLibs, 'META-INF/MANIFEST.MF').forEach { 
  file -> logger.lifecycle('File: ' + file.absolutePath) 
}

Outputs a nice:
File: Z:\test\_test\build\minecraftforge\forgegradle\zip_data\82390308e0b67205bf0d0d507dc48e0d71410bf7\json-20260719\META-INF\MANIFEST.MF

In addition this defacto standardizes the Facade files in deps to:
A space separated list in the FORGE_FACADE manifest attribute OR META-INF/facades.cfg

Javadocs need to be written.
Do you think I should promote the BiFunction<File, JarFile, List<ZipEntry>> to a proper EntryFinder interface and expose a mapZip(FileCollection, EntryFinder)?

Adding support for the access transformer helper requires parsing the mods.toml, as such I have to add a TOML dependency, so I add Jezza Toml which adds ~30kb to the jar. Same library I use for Renamer.

The functions that take Object instead of FileCollection just pass it directly to project.files as a small helper to make cleaner build files.

mapZip(files, name) just grabs the explicit file from any archive that has it
mapAccessTransformers(files) tries to find ATs from the manifest, toml, and default location
mapFacace(files) tries to find the facade config from the manifest, or default location

@LexManos
LexManos marked this pull request as draft August 7, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant