Alternative to AppendingTransformer in Maven shade plugin

408 views
Skip to first unread message

tony....@rubrik.com

unread,
Dec 19, 2017, 5:26:43 PM12/19/17
to bazel-discuss
Our maven build depends on multiple libraries that use a reference.conf file.
But when we create our deployment jar, the reference.conf file gets overwritten.
In order to remedy this behavior in Maven, we used the AppendingTransformer in the shade plugin like so:
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
    <resource>reference.conf</resource>
</transformer>

I'm wondering if there is a similar thing that can be done with Bazel? This is perhaps the last barrier preventing us from switching over to Bazel.

Thanks for reading,
Tony

tony....@rubrik.com

unread,
Dec 21, 2017, 4:31:42 PM12/21/17
to bazel-discuss
This is the documentation in akka on needing to merge the reference.conf files.
https://doc.akka.io/docs/akka/snapshot/general/configuration.html

It looks like we have always used the default configuration settings, which is why only we're seeing the issue with bazel.

tony....@rubrik.com

unread,
Jan 5, 2018, 4:42:13 PM1/5/18
to bazel-discuss
The sbt project ran into this issue in the past: https://github.com/sbt/sbt-assembly/issues/36
Maven dependencies that have reference.conf files would get those configuration files overwritten when the jars get merged.

I did some more digging around and it looks like bazel deploy jar uses the SingleJar tool to merge multiple jars, and it already employs a concatenation strategy on a few potentially conflicting files: https://github.com/bazelbuild/bazel/blob/master/src/java_tools/singlejar/java/com/google/devtools/build/singlejar/DefaultJarEntryFilter.java

Would it be appropriate to add references.conf as a file that should be concatenated in the DefaultJarEntryFilter?: https://github.com/bazelbuild/bazel/blob/master/src/java_tools/singlejar/java/com/google/devtools/build/singlejar/DefaultJarEntryFilter.java

Another potential solution could be to expose a flag in SingleJar that would allow users to specify the concatenation merge policy for specific files.
Reply all
Reply to author
Forward
0 new messages