Even if I add an exclude rule to exclude "com.google.guava:guava", if other dependencies are rewritten to "com.google.guava:guava", I will still get it in the dependency graph.
Take following project for example:
plugins {
id 'java'
}
repositories {
mavenCentral()
}
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module("com.jcraft:jsch") using module("com.google.guava:guava:20.0") because "No reason, just for test"
}
exclude group: "com.google.guava", module: "guava"
}
dependencies {
implementation group: 'org.apache.hadoop', name: 'hadoop-common', version: '2.6.0'
}
I already added an exclude rule: exclude group: "com.google.guava", module: "guava"
However, I still get guava in my dependency graph
Expected Behavior
If I exclude a dependency, I should not have it in my dependency graph anymore. No matter what.
and then run ./gradlew dependencyInsight --dependency com.google.guava:guava --configuration compileClasspath,
You will still get guava in the compileClasspath.
➜ test-gradle-exclude-with-substitution git:(main) ./gradlew dependencyInsight --dependency com.google.guava:guava --configuration compileClasspath
> Task :dependencyInsight
com.google.guava:guava:20.0 (selected by rule)
variant "compile" [
org.gradle.status = release (not requested)
org.gradle.usage = java-api
org.gradle.libraryelements = jar (compatible with: classes)
org.gradle.category = library
Requested attributes not found in the selected variant:
org.gradle.dependency.bundling = external
org.gradle.jvm.environment = standard-jvm
org.gradle.jvm.version = 8
]
com.jcraft:jsch:0.1.42 -> com.google.guava:guava:20.0
\--- org.apache.hadoop:hadoop-common:2.6.0
\--- compileClasspath
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 1s
Context
Our company has some dependency substitution rules and every project is required to use. With this bug, each individual project is unable to exclude dependencies cleanly.
Even if I add an exclude rule to exclude "com.google.guava:guava", if other dependencies are rewritten to "com.google.guava:guava", I will still get it in the dependency graph.
Take following project for example:
I already added an exclude rule:
exclude group: "com.google.guava", module: "guava"
However, I still get guava in my dependency graph
Expected Behavior
If I exclude a dependency, I should not have it in my dependency graph anymore. No matter what.
Current Behavior
clone this repo: https://github.com/attix-zhang/test-gradle-exclude-with-substitution
and then run
./gradlew dependencyInsight --dependency com.google.guava:guava --configuration compileClasspath
,You will still get guava in the compileClasspath.
Context
Our company has some dependency substitution rules and every project is required to use. With this bug, each individual project is unable to exclude dependencies cleanly.
Steps to Reproduce (for bugs)
You will still find guava.
Your Environment
Macbook Big Sur 11.5.1 Java: