Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I exclude dependencies brought in from other sub-projects?

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?

like image 605
user447607 Avatar asked Nov 25 '15 21:11

user447607


People also ask

How do I exclude in dependencies build Gradle?

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.

How do I exclude a specific version of a dependency in Maven?

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.

What is exclusion in POM XML?

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.


1 Answers

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 } 
like image 53
Stanislav Avatar answered Oct 08 '22 15:10

Stanislav