I'm using the latest version (7.1.2
) of the ShadowJar
(Gradle) plugin to build the application's JAR. I'm trying to exclude some dependencies from the resultant JAR, so I have configured the plugin like:
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
...
tasks.withType(ShadowJar) {
final def attributes = [
// ...all the attributes here
]
dependencies {
// Dependencies that are already provided in the lib/ folder of Apache Flink
exclude(dependency("org.apache.flink:flink-clients_2.12"))
exclude(dependency("org.apache.flink:flink-java"))
exclude(dependency("org.apache.flink:flink-streaming-java_2.12"))
}
manifest.attributes(attributes)
mergeServiceFiles()
minimize()
setZip64(true)
}
It's not clear to me what dependencies are actually begin excluded/included — when unzipping and visually analyzing the generated ZIP file(s). I've been trying to compare the generated (ZIP) -shadow
file with the one generated by the distZip
task, but the -shadow
one doesn't have a single JAR on it...only classes.
So I'm wondering if there is a way to print the effective group of dependencies that are going to be part of the final JAR file.
Based on the
ShadowJar
's documentation, the default configuration is to merge all dependencies from the project'sruntimeClasspath
, but./gradlew dependencies --configuration runtimeClasspath
doesn't account for the excluded ones.
In the shadow jar you'll find the
META-INF/maven
folder, there you'll find all the pom.xml files, each containing the dependency version.