How to make a shadow jar from a third party JAR that is distributed as a zip

34 views Asked by At

The Google BigQuery JDBC jar is distributed as a downloadable zip. A lot of its dependencies are gRPC related, but we're also using gRPC. This has caused conflicts in the past where we had to go remove conflicting version jars from the provided /libs. So far we haven't run into issues from doing so, but I'm worried at some point a version discrepancy will cause some sort of runtime issues.

We currently include it in our Gradle project with:

gradle.taskGraph.whenReady {
    allTasks
        .filter { it.hasProperty("duplicatesStrategy") }
        .forEach {
            it.setProperty("duplicatesStrategy", "EXCLUDE")
        }
}

dependencies {
...
    implementation(fileTree(mapOf("dir" to "libs/SimbaJDBCDriverforGoogleBigQuery42_1.3.3.1004/", "include" to listOf("*.jar"))))
...
}

I see Dremio created a maven project to shade the jar themselves, but this is pretty old and we use Gradle. I imagine something like this is also possible in Gradle, but I'm not sure how to go about it.

My guess so far is:

  1. Set up a subproject in gradle for shading BQ
  2. Manually configure all the dependencies in the gradle project with versions matching those in the /libs dir.
  3. Somehow tell this project to build the shaded BQ jar?
  4. Somehow tell our main project that it depends on that shaded jar?

If there's easier ways to accomplish this I'm all ears!

0

There are 0 answers