[GRADLE-3236] Multiple Component Selection Rules for same module fail to resolve metadata Created: 04/Feb/15  Updated: 19/Mar/15  Resolved: 04/Feb/15

Status: Resolved
Project: Gradle
Affects Version/s: 2.2.1, 2.3-rc-1
Fix Version/s: 2.4-rc-1

Type: Bug
Reporter: Gary Hale Assignee: Gary Hale
Resolution: Fixed Votes: 0

Issue Links:
Related
Related to GRADLE-3216 Using changing provided by component ... Resolved

 Description   

When there is a module that is referenced from multiple component selection rules and those rules require metadata, only the latest version successfully resolves the metadata. If another rule rejects that version, that rule will fail on subsequent versions because it can't resolve the metadata for those versions from the cache.

For example:

build.gradle
repositories {
    ivy {
        url "http://ivyroundup.googlecode.com/svn/trunk/repo/modules"
        layout "pattern", {
            ivy "[organisation]/[module]/[revision]/ivy.xml"
            artifact "[organisation]/[module]/[revision]/packager.xml"
        }
    }
}
 
configurations {
    modules
    modulesA {
        extendsFrom modules
        resolutionStrategy {
            componentSelection {
                all { ComponentSelection selection, IvyModuleDescriptor ivy ->
                    println "A is evaluating ${selection.candidate}"
                    if (selection.candidate.version != "1.8.1") { selection.reject("rejected by A") }
                }
            }
        }
    }
    modulesB {
        extendsFrom modules
        resolutionStrategy {
            componentSelection {
                all { ComponentSelection selection, IvyModuleDescriptor ivy ->
                    println "B is evaluating ${selection.candidate}"
                    if (selection.candidate.version != "1.8.0") { selection.reject("rejected by B") }
                }
            }
        }
    }
}
 
dependencies {
    modules("org.apache.ant:ant:1.+") { transitive = false }
}
Output
$ gradle dependencies
:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

modules
\--- org.apache.ant:ant:1.+ -> 1.8.4

modulesA
A is evaluating org.apache.ant:ant:1.8.4
\--- org.apache.ant:ant:1.+ FAILED

modulesB
B is evaluating org.apache.ant:ant:1.8.4
\--- org.apache.ant:ant:1.+ FAILED

BUILD SUCCESSFUL

Note that once the metadata is successfully cached, the dependency will successfully resolve, so reproducing the issue requires a clean metadata cache.



 Comments   
Comment by Gary Hale [ 04/Feb/15 ]

This issue is fixed in 2.4.

Comment by Gary Hale [ 04/Feb/15 ]

Similar issue

Generated at Wed Jun 30 12:43:32 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.