Error Reporting: Configuration with name 'default' not found

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;

Thanks, I’ve raised this as GRADLE-3375. Would you perhaps consider contributing a fix for this?

Do you require unit tests for it or so? If yes - this will take too much effort from me, i.e. to make proper unit testing.

I don’t think additional tests would be strictly required for this. If there are existing tests they might need to be updated to look for the new error message.