In some conditions Gradle fails to build the project with error message like:
Could not resolve all dependencies for configuration ‘:project:subproject:compile’.
Configuration with name ‘default’ not found.
this happens because of this code:
package org.gradle.api.internal.artifacts.dependencies;
public class DefaultProjectDependency extends AbstractModuleDependency implements ProjectDependencyInternal {
...
public Configuration getProjectConfiguration() {
return dependencyProject.getConfigurations().getByName(getConfiguration());
}
...
}
getConfiguration() for project dependencies actually always return ‘default’, however such configuration is not always present in some target projects. Exception report gives absolutely no clue about exact cause of the error - in multi-module projects that exception can actually come from the 10th level of dependency from the original project reported in exception.
Please provide more intelligent error reporting of that case, for example like following:
public Configuration getProjectConfiguration() {
String name = getConfiguration();
Configuration configuration = dependencyProject.getConfigurations().findByName(name);
if( configuration == null ) {
throw new UnknownConfigurationException(String.format(
"Configuration with name %s is not found in %s, available configurations: %s",
name, dependencyProject, dependencyProject.getConfigurations()));
}
return configuration;
}