this syntax may be not yet provided but I am asking to avoid redundant code. Right now I am excluding jars like this
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 multiple groups/modules on a single 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 is there any other short code which does the same thing.
Thank You.
Within the closure we call exclude , passing: group the group of the artifact we want to exclude. module the name of the artifact we want to exclude. This is equivalent to the name used to declare a dependency in Gradle.
At runtime, Gradle will locate the declared dependencies if needed for operating a specific task. The dependencies might need to be downloaded from a remote repository, retrieved from a local directory or requires another project to be built in a multi-project setting. This process is called dependency resolution.
The Gradle build pulls all dependencies down from the Maven Central repository, as defined by the repositories block. Let's focus on how we can define dependencies.
If you set transitive=false, then the io. fabric. sdk. android. Fabric class will not be found at compile time.
You could 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 is leveraging a Groovy feature, not a Gradle feature.
Note also that I don't believe that include
is a thing in this context (see the method summary here).
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