Can't resolve transitive dependencies by myself

I have a flink project. Which has transitive guava dependencies. Simplified it looks like this:
+--- foo
| +--- bar
| | +--- guava:1.5
| +--- biz
| | +--- guava:1.3
+--- foo
| +--- bar
| | +--- guava:1.5
| +--- biz
| | +--- guava:1.3
If I set 1.5, it ruins biz and if I set 1.3 it ruins bar (these versions do not represent my real project and i put them here just as an example) How to force gradle to set exact dependencies for dependencies dependencies?
5 Replies
JavaBot
JavaBot3y ago
This post has been reserved for your question.
Hey @Lil Villa! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Lil Villa
Lil VillaOP3y ago
Dependencies output with every other dependency which does not have guava as a dependency excluded -> https://gist.github.com/tomazvila/1837a33228cecdb9fbc2e7985eee94e3
Gist
gauva transitive dependencies
gauva transitive dependencies. GitHub Gist: instantly share code, notes, and snippets.
Lil Villa
Lil VillaOP3y ago
main flink gradle file:
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id 'application'
id 'myproject.scala-conventions'
id 'com.github.johnrengelman.shadow'
}

sourceSets.main.compileClasspath += configurations.flinkShadowJar
sourceSets.main.runtimeClasspath += configurations.flinkShadowJar
sourceSets.test.compileClasspath += configurations.flinkShadowJar
sourceSets.test.runtimeClasspath += configurations.flinkShadowJar
run.classpath = sourceSets.main.runtimeClasspath

dependencies {
implementation "org.apache.flink:flink-streaming-scala_${scalaVersion}:${flinkVersion}"
implementation "org.apache.flink:flink-clients:${flinkVersion}"
flinkShadowJar project(':commons')
flinkShadowJar 'org.apache.flink:flink-connector-kinesis:1.15.2'
flinkShadowJar "org.apache.hadoop:hadoop-aws:${hadoopVersion}"
}


tasks.withType(ShadowJar).configureEach {
zip64 true
from project.sourceSets.main.runtimeClasspath
configurations = [ project.configurations.flinkShadowJar ]
// https://github.com/johnrengelman/shadow/blob/master/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.groovy#L86
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'module-info.class')
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id 'application'
id 'myproject.scala-conventions'
id 'com.github.johnrengelman.shadow'
}

sourceSets.main.compileClasspath += configurations.flinkShadowJar
sourceSets.main.runtimeClasspath += configurations.flinkShadowJar
sourceSets.test.compileClasspath += configurations.flinkShadowJar
sourceSets.test.runtimeClasspath += configurations.flinkShadowJar
run.classpath = sourceSets.main.runtimeClasspath

dependencies {
implementation "org.apache.flink:flink-streaming-scala_${scalaVersion}:${flinkVersion}"
implementation "org.apache.flink:flink-clients:${flinkVersion}"
flinkShadowJar project(':commons')
flinkShadowJar 'org.apache.flink:flink-connector-kinesis:1.15.2'
flinkShadowJar "org.apache.hadoop:hadoop-aws:${hadoopVersion}"
}


tasks.withType(ShadowJar).configureEach {
zip64 true
from project.sourceSets.main.runtimeClasspath
configurations = [ project.configurations.flinkShadowJar ]
// https://github.com/johnrengelman/shadow/blob/master/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.groovy#L86
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'module-info.class')
}
commons:
plugins {
id 'myproject.scala-conventions'
}

dependencies {
implementation "org.apache.hadoop:hadoop-aws:${hadoopVersion}"
implementation "org.apache.hadoop:hadoop-common:${hadoopVersion}"
implementation "org.apache.hadoop:hadoop-client:${hadoopVersion}"
}
plugins {
id 'myproject.scala-conventions'
}

dependencies {
implementation "org.apache.hadoop:hadoop-aws:${hadoopVersion}"
implementation "org.apache.hadoop:hadoop-common:${hadoopVersion}"
implementation "org.apache.hadoop:hadoop-client:${hadoopVersion}"
}
JavaBot
JavaBot3y ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
Lil Villa
Lil VillaOP3y ago
Problem is not with flink guava dependencies, but with different scala versions.

Did you find this page helpful?