Upcoming Gradle 2.2 contains new incubating component replacement rules: dependencies { components { module("com.google.collections:google-collections").replacedBy("com.google.guava:guava") } }
See more in http://www.gradle.org/docs/nightly/release-notes. This declaration is used during conflict resolution, Gradle will prevent both collections and guava appear in the same dependency tree, preferring any version of guava over every version of collections. Most importantly, if the dependency tree _only_ contains collections it will _not_ be replaced (because there is no conflict). Multiple modules can have the same target replacement. However, we don't support (yet) having single module replaced by multiple modules. The full DSL in the current form, based on our previous discussion on the mailing list. I'm starting new email thread on purpose (for good or bad, let's see whether it helps). dependencies { components { //declaring replacement: module("com.google.collections:google-collections").replacedBy("com.google.guava:guava") module(someModuleIdentifier).replacedBy("com.google.guava:guava") //querying for the replacement target: ModuleIdentifier id = module("com.google.collections:google-collections").getReplacedBy() //querying for the replacement source: ModuleIdentifier id = module("com.google.collections:google-collections").getId() } } Javadoc (for interface names, etc.): http://www.gradle.org/docs/nightly/javadoc/org/gradle/api/artifacts/dsl/ComponentMetadataHandler.html#module(java.lang.Object) This DSL can grow to accommodate features like: a) replacing single module with a set of modules. I'd love to have this. I also want to make incremental progress. b) other component module metadata (e.g. releasable units, impl module consistent with api module). I'd love to have this, too. Let's confirm this API and/or make changes to it before 2.2 release. Other related APIs that we should have in mind (for consistency): 1. component selection rules: configurations.conf.resolutionStrategy { componentSelection { all { ComponentSelection selection -> if (selection.candidate.group == 'org.sample') { selection.reject("rejecting experimental") } } module("org.sample:api") { ComponentSelection selection -> if (selection.candidate.version == "1.1") { selection.reject("known bad version") } } } } 2. component metadata rules: dependencies { components { eachComponent { ComponentMetadataDetails details, IvyModuleDescriptor ivyModule -> if (details.id.group == 'my.org' && ivyModule.branch == 'testing') { details.changing = true } } } } Cheers! -- Szczepan Faber Core dev@gradle; Founder@mockito --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email