I have a huge dependency (Spark) that I use in compileOnly
configuration, and several other libraries. I am trying to build a fat jar, of course, without compileOnly
dependencies. Gradle does this fine, however, several libraries declare compile
/runtimeOnly
dependencies that are also dependencies of compileOnly
huge dependency, like:
my-module
|-> compileOnly: spark
| ...
| \-> compile: scala-reflect
| ...
\-> implementation: library
...
\-> runtimeOnly: scala-reflect
That causes scala-reflect
to be included into jar as runtime dependency, that I am trying to avoid. Scala is taken here only as example, there are actually more like that (Jackson, parts of Apache Commons, …).
Is there way to enforce compileOnly
trainsitional dependencies?
As I can see, I can manually exclude
those transitive dependencies and redeclare them as compileOnly
, but that would be a little mess (did I miss any? did I excluded something that is not actually provided?).