Got a multi-project build where many modules depend on jboss libraries. A few of these modules have broken descriptors. For example, one library creates a circular dependency on itself, which causes Gradle to stack overflow, and another depends on gnu getopts, but specifies the wrong group name.
I know how to fix these problems in a single build file (through exclusions), but I have to redo it in each subproject.
I also know how to extract the declaration out into a helper method defined in the root project. E.g.:
apply from: ‘…/common.dependencies.gradle’
addCompileJbossDependency()
(the messiness of declaring the right exclusions, and maybe adding the additonal libraries is done in the method).
But I was wondering if there was a clean way to have the root project silently modify all dependencies of all subprojects which declare the offending dependencies. Like, in my subproject, I could just declare the dependency the normal way:
compile ‘org.jboss:jboss-security:1.0’
and in the root project, do something like:
allprojects {
if(dependencies.contains(‘org.jboss:jboss-security:1.0’) {
getDependency().exclude(‘org.gnu:getopts:1.0’)
dependencies.compile ‘gnu.getopts:java-getopts:1.0’ }
Something like that. I guess akin to Maven’s dependency management, where I can modify all usages of a dependency in one place.