Goooler / shadow

This is a fork of johnrengelman/shadow.
https://plugins.gradle.org/plugin/io.github.goooler.shadow
Apache License 2.0
61 stars 2 forks source link

`Relocate` should remove empty folder after relocating. #92

Open Geno1024 opened 7 months ago

Geno1024 commented 7 months ago

Please check the User Guide before submitting "how do I do 'x'?" questions!

Shadow Version

id("io.github.goooler.shadow") version "8.1.7"

Gradle Version

8.6

Expected Behavior

Avoiding X-Y problem:

X: I am working for a company, then written all code with the package name containing my company according to my company's regulations. However, in some specific scenarios, my leader tells me to hide / replace all my company name specific info. So I have to "move" all package names to other name.

Y: I want to use relocate to move all sources under specific packages (that definitely controllable by my own, and the specific package name doesn't used by any other dependencies) to other name.

Actual Behavior

All classes have been moved to the new package name, but the old package empty folder still exists in the production jar file.

Hope to remove empty folder after relocate post-processing.

Gradle Build Script(s)

tasks.withType<ShadowJar> {
    isEnableRelocation = true
    relocate("[REDACTED due to company security reason]", "com.shadow")
    archiveClassifier = "shadowed"
}

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

META-INF/ META-INF/MANIFEST.MF com/ com/[REDACTED]/ com/[]/[]/ com/[]/[]/[]/ com/[]/[]/[]/[]/ com/[]/[]/[]/[]/library/ com/shadow/library/[].class com/shadow/library/[].class com/shadow/library/[].class com/shadow/library/[].class com/shadow/library/[].class com/[]/[]/[]/[]/library/level1/ com/[]/[]/[]/[]/library/level1/level2/ com/shadow/library/level1/level2/[].class com/shadow/library/level1/level2/[].class [et cetera]

Geno1024 commented 7 months ago

Possible duplicate of https://github.com/johnrengelman/shadow/issues/53 and https://github.com/johnrengelman/shadow/issues/57.

Though I am providing a MCVE, but I will provide one if you need.