Gradle: exclude and include multiple groups / modules in one line from compilation close

this syntax may not yet be presented, but I ask you to avoid redundant code. Right now I rule out such jars

compile ('com.mygroup:myJar:0.1.1-M1-SNAPSHOT+') { exclude group: 'org.apache.xmlgraphics' exclude group:'org.apache.avalon.framework' exclude group:'net.engio' exclude group: 'com.google.guava' } 

How can I exclude several groups / modules in one line of code, for example, this syntax

 compile ('com.mygroup:myJar:0.1.1-M1-SNAPSHOT+'){ exclude group: ['org.apache.xmlgraphics', 'org.apache.avalon.framework', 'net.engio', 'com.google.guava'] } 

Or there is another short code that does the same.

Thanks.

+5
source share
2 answers

You can do something like this:

 compile ('com.mygroup:myJar:0.1.1-M1-SNAPSHOT+'){ ['org.apache.xmlgraphics', 'org.apache.avalon.framework', 'net.engio', 'com.google.guava'].each { exclude group: it } } 

Note that this uses the Groovy function, not the Gradle function.

Note also that I do not think that include is a thing in this context (see the summary of methods here ).

+4
source
 compile ('com.mygroup:myJar:0.1.1-M1-SNAPSHOT+'){dep -> ['org.apache.xmlgraphics', 'org.apache.avalon.framework', 'net.engio', 'com.google.guava'].each {group -> dep.exclude group: group } } 

Refer to this .

0
source

All Articles