This is not a duplicate since those other solutions did not work.
I have a sub-project:
:commons:widget
gradle.build (sub-project) resembles this:
configurations {providedCompile} dependencies { compile project(":commons:other-widget") ...other dependencies... }
If you display the dependencies:
+--- project :commons:some-other-project +--- project :commons:exclude-me-project (*) \--- org.apache.cxf:cxf-rt-frontend-jaxrs: -> 3.0.3 (*)
What doesn't work:
Any of the usual syntax. I've tried every variation I can think of. Even went looking for the API but was unable to find what I need there.
In this project's dependencies section: ...
compile project(":commons:some-other-project") { exclude (":commons:exclude-me-project") }
Result:
Could not find method exclude() for arguments [:commons:some-other-project] on project
I've also tried:
compile ( project (':commons:some-other-project') ) { transitive = false }
Result: Instead of removing dependencies of ":commons:some-other-project", it removes ":commons:some-other-project".
I have a large and complicated project to convert. I've a lot of this sort of work ahead of me. Given a project as a dependency, how do I exclude things from it?
Option 1) per-dependency exclude rules. When you specify a dependency in your build script, you can provide an exclude rule at the same time telling Gradle not to pull in the specified transitive dependency. For example, say we have a Gradle project that depends on Google's Guava library, or more specifically com.
Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.
Exclusions are set on a specific dependency in your POM, and are targeted at a specific groupId and artifactId. When you build your project, that artifact will not be added to your project's classpath by way of the dependency in which the exclusion was declared.
exclude
for dependencies has a little bit another syntax, so try to do it providing the module name, which is equals to the exclude-me-project
name, like:
compile(project(":commons:some-other-project")) { exclude module: "exclude-me-project" }
Alternatively, you may exclude all the transitive dependencies for commons
project, but it will remove all the deps of the some-other-project
project, including the exclude-me-project
:
compile(project(":commons:some-other-project")) { transitive = false }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With