Reputation: 10925
I configure dependency using shadow
scope added by Gradle Shadow Plugin:
dependencies { shadow "org.apache.flink:flink-java:$flinkVersion" }
As per documentation, this dependency should not be present in shadow JAR (which is true), it should be on compile classpath (with is true as well), but I don't have this dependency on runtimeClasspath
configuration. What am I doing wrong?
Upvotes: 2
Views: 877
Reputation: 5167
I suspect the documentation is wrong. Shadow builds jar from runtimeClasspath
configuration, which makes it impossible to build different artifacts from runtime dependencies. https://github.com/johnrengelman/shadow/blob/829647a06971ebc96c7d3df717f9a4e92811b602/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.groovy#L84-L85
Workaround is possible with intermediate configuration and redirecting shadow
to contribute to runtimeClasspath
configurations {
// alternative "runtimeClasspath" configuration to provide to shadowJar configuration
create("uberJar") {
extendsFrom(configurations.runtimeOnly.get(), configurations.implementation.get())
isCanBeResolved = true
isCanBeConsumed = false
}
}
configurations.runtimeClasspath {
extendsFrom(configurations.shadow.get())
}
tasks.shadowJar {
configurations = listOf(project.configurations.named("uberJar").get())
}
Upvotes: 1