bazeltools / bazel_jar_jar

JarJar rules for bazel (rename packages and classes in existing jars)
Apache License 2.0
18 stars 23 forks source link

support scala jars better #32

Open johnynek opened 1 year ago

johnynek commented 1 year ago

see the code here:

https://github.com/eed3si9n/jarjar-abrams/blob/develop/core/src/main/scala/com/eed3si9n/jarjarabrams/scalasig/EntryTable.scala#L38

these rules aren't currently touching scala signatures (and I don't know if kotlin has something similar).

cc @eed3si9n

sheilahu commented 1 year ago

Hi @johnynek I'm trying to use the rule for shading java and scala dependencies to build a fat scala jar. I first use java_binary to get the implicit <name>_deploy.jar as a fat jar, then use bazel_jar_jar to shade dependencies.

For a simple rule like this:

 inline_rules = [
        "rule com.typesafe.** shaded.@0",
        "zap scala.**",
        "zap java.**",
    ],

once imported it's still asking for the unshaded version of the library.

error: Symbol 'type com.typesafe.scalalogging.LazyLogging' is missing from the classpath.
This symbol is required by 'class MyClass'.
Make sure that type LazyLogging is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MyClass.class' was compiled against an incompatible version of com.typesafe.scalalogging.

I tried this with another Java library, similar error.

Once I decompiled the bytecode into Java file, it's showing me correctly that the dependency was shaded inside MyClass.

Wonder if this has anything to do with the scala signature and reflection?

Thanks.