Shadowfacts' Forgelin

Shadowfacts' Forgelin

108M Downloads

Shading/Bundling Forgelin

Eladkay opened this issue ยท 13 comments

commented

When building a mod with Forgelin shaded I get this error:

 Execution failed for task ':reobfJar'.
 java.util.zip.ZipException: duplicate entry: META-INF/kotlin-stdlib.kotlin_module

Talking to @JamiesWhiteShirt it seems expected but I still would like to see if there's anything that could be done to make Forgelin shadeable. In this specific case I really cannot use a lib mod.

commented
  1. The whole point of Forgelin is so that multiple mods don't have to shade the Kotlin libraries themselves :V
  2. Are you shading the Kotlin libs and Forgelin? Forgelin itself bundles the Kotlin libs so if you're shading Forgelin, you don't need to shade Kotlin.
commented

Not shading the kotlin libs themselves. Only shading Forgelin and another, completely unrelated library.

commented

Can you post a Gist of your build.gradle file (and gradle.properties/build.properties if you have it)?

commented

I didn't even know ForgeGradle can take plugins. I'll look into that. How is it related to the problem though? The problem seems to be some sort of double-shading problem.

commented

Instead of using the old method of shading, try using the Shadow Gradle plugin.

commented

With the Shadow plugin you can whitelist certain dependencies to shade and exclude transitive dependencies which I don't believe can be done with the old method.

commented

What would I whitelist/blacklist? Forgelin's Kotlin dependency?

commented

Forgelin has Kotlin shaded and it transitively depends on Kotlin so there are technically two copies of Kotlin in your project. Since you're shading the Forgelin jar which has Kotlin builtin and transitively depends on Kotlin, you're getting two copies of Kotlin shaded.

You would have something like this in your build.gradle:

dependencies {
    compile "net.shadowfacts:Forgelin:1.1.0"
}

shadowJar {
    dependencies {
        include(dependency("net.shadowfacts:Forgelin:1.1.0"))
        include(dependency("joda-time:joda-time:2.9.6"))
    }
}

You would also need to remove the required configuration and the jars block from your build.gradle.

commented

Ok, thanks!

commented

Even if this resolves this specific problem, there is another issue related to shading. If a mod using Forgelin 1.1.0+ adds something to the manifest, I am fairly sure there will be a conflict with the manifest file. It might actually be a bad idea all together. I don't know what FML will do when there are several jars with manifests pointing to the same FML core mod.

I firmly believe it should not be recommended to shade Forgelin, mostly because of multiple mods shading the same dependency. This further reinforces it.

commented

Yes, I agree that shading dependencies is seldom a good idea, but in this specific case it is required and it is not likely to cause any problems.

commented

The recommendation has always been not to shade Forgelin, because it defeats its entire purpose as well as potentially causing conflicts.