We get the following performance issue from the build scan result: "Dependency resolution during project configuration may reduce build speed by resolving dependencies unnecessarily."
We followed the link to the documentation but still don’t know what to do to avoid this problem. From our perspective, we follow the Gradle documentation about setting up configurations.
We get this error for every configuration we created in our build.
The build scan doesn’t yet do a good job of telling you where it is used in your build. To do that, you can add this script to the top of your build:
def afterEvaluation = false
gradle.projectsEvaluated {
afterEvaluation = true
}
allprojects { project ->
configurations.all { configuration ->
configuration.incoming.beforeResolve {
if (!afterEvaluation) {
throw new Exception("Configuration $configuration.name of project $project.name is being resolved at configuration time.")
}
}
}
}
The thrown stack trace should indicate where resolution is happening. If it’s not clear from the stacktrace, please share the trace with me (you can use private messages here if necessary) and I can help.
@luke_daley thank you for the code that helped us to identify the problematic configuration.
The build scan showed us all manually added configurations as problematic. But at the end
it turned out that it was enough to fix one problematic place where we iterate over the files of a config.
This is the problematic piece of code in a configuration of a copy task:
coreProjects().each { plugin ->
from plugin.configurations.job.files
}
So the question is now how to do this copy task config lazy?
@luke_daley We would like to let this code permanent in our build to avoid the same issue again. Do you see a problem in having that check enabled all the time?
Hello, not sure if I should start my own question or use this one.
I get the same error and after adding the snippet you mentionned, I don’t understand the stacktrace.
A problem occurred configuring project ':collections'.
> Failed to notify dependency resolution listener.
> Configuration kotlinScriptDef of project collections is being resolved at configuration time.