In a custom gradle task that I run in a gradle war project I am trying to add some existing dependencies to the providedCompile configuration
Configuration providedCompileConf = project.getConfigurations().findByName("providedCompile");
if(providedCompileConf==null) {
throw new RuntimeException("This task is not supported");
}
List<ResolvedDependency> transitiveDependencies = computeTransitiveDeps(project);
for (ResolvedDependency dep : transitiveDependencies) {
providedCompileConf.getAllDependencies().add(buildDependency(dep));
}
}
private Dependency buildDependency(final ResolvedDependency dep) {
return new Dependency() {
@Override
public String getVersion() {
return dep.getModuleVersion();
}
@Override
public String getName() {
return dep.getModuleName();
}
@Override
public String getGroup() {
return dep.getModuleGroup();
}
@Override
public Dependency copy() {
// Hm will this work?
return this;
}
@Override
public boolean contentEquals(Dependency dependency) {
return false;
}
};
}
but I get this error:
add() is not supported on CompositeCollection without a CollectionMutator strategy
Is there a simpler way to add dependencies to a configuration or am I missing some basic knowledge here?