So the case is this, in the build.gradle file in the dependency structure I have
dependencies {
compile 'A'
compile 'B'
}
However I want people to be able to compile either just A or just B, is there a way to know for instance whether the dependency A was used by returning a global boolean that can be used somewhere else, in a gradle task?
so in other words
if (A was compiled) {
compile A;
} else {
exclude A;
}
You could get all compile dependencies like this:
def compile = configurations.compile.allDependencies*.with{"$it.group:$it.name:$it.version".toString()}
It would return list of all dependencies in group:name:version
format. Then you could just use:
if("org.codehaus.groovy:groovy-all:2.4.7" in compile) {
println "org.codehaus.groovy:groovy-all:2.4.7 was compiled"
}
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