Keeping contents of the meta-inf folder

I have a gradle plugin that puts files in META-INF/jars and I want to keep these in the output jar, but ProGuard removes them. Is there any way to copy over these files with ProGuard? I have tried -keepdirectories META-INF/jars, but that doesn’t work.

This was a very stupid error. It turns out that ProGuard wasn’t touching those files but my gradle configuration was. I was using this.injars(tasks.named<Jar>("jar").flatMap { it.archiveFile }) in my ProGuard gradle task. I had to switch it to this.injars(project.layout.buildDirectory.file("libs/${["archives_base_name"]}-debug-${["version"]}.jar"))

This is because those jars in META-INF weren’t added until after the Jar task. I had to point it at the final file on the disk. For anyone else trying to find this fix in the future this was using Fabric Loom and include() to bundle libraries.

1 Like