Using configuration.incoming.beforeResolve {} to add extra dependencies?

(Erik Eloff) #1

I’m writing a plugin simplifying collecting a number of default dependencies, configurable via an extension. I’m doing this in a similar way to the jacoco-plugin [1]

fooConfig.incoming.beforeResolve {
    if (fooConfig.dependencies.empty) {
        fooConfig.dependencies.add ....
// Use all
configurations.compile.extendsFrom fooConfig

However, compile configuration doesn’t get those dependencies, but fooConfig does (according to gradlew dependencies). It seems that that beforeResolved isn’t executed until fooConfig is resolved explicitly.

How can I make sure that the dependencies are added to fooConfig (and compile) configuration in time, and still doing it lazily? Should I handle this in another way?