[GRADLE-2873] configuration.setExtendsFrom() may not clear all previous targets Created: 21/Aug/13  Updated: 02/Sep/13  Resolved: 02/Sep/13

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.8-rc-1

Type: Bug
Reporter: Szczepan Faber Assignee: Szczepan Faber
Resolution: Fixed Votes: 0

Known Issue Of:
1.7

 Description   

If the same configuration is added to extendsFrom multiple times then setExtendsFrom() does not behave correctly and fails to clear out dependencies from previous extends-from targets.

It affects earlier versions of Gradle, too.

Here's an example:

configurations {
  foo
  bar
  baz
}

repositories { 
  mavenCentral() 
}

dependencies {
  foo 'junit:junit:4.10'
  bar 'org.mockito:mockito-core:1.9.5'
}

configurations.baz.extendsFrom configurations.foo
//2nd time:
configurations.baz.extendsFrom configurations.foo

assert configurations.baz.allDependencies*.name == ['junit']

configurations.baz.extendsFrom = [configurations.bar]

//fails:
assert configurations.baz.allDependencies*.name == ['mockito-core']

//workaround:
if (!configurations.baz.extendsFrom.contains(configurations.foo)) {
  configurations.baz.extendsFrom configurations.foo
}

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