Do not download dependencies for all configurations

Im trying to figure out the logic of downloading dependencies from Maven and it looks like Gradle downloads all dependencies prior to build (even for configurations I am not using in this particular build).

I.e. Im trying to execute assemble target (this is an Android project) which in theory doesn’t execute any tests. So I expect it to download only dependencies related to compile configuration. Instead Im seeing Gradle downloading all the possible dependencies including ones related to test configuration.

Is this an expected behavior? Is it possible to have some sort of “download on demand” rule?

Dependencies are downloaded only when a configuration they belong to is resolved.

So two possibilities here:

  • Your unexpectedly downloaded artifacts belongs to the compile configuration
    Or
  • you call another task that resolves the testCompile configuration

Thanks!

It looks like these dependencies are resolved during :buildSrc:build task (I have some custom plugins in buildSrc dir). Looking at my custom plugins I doesn’t look like I am resolving configurations there.

Will dig deeper into that…

Ok, ping back if you need help.
I myself experienced some unexpected configuration resolution, but in the end, after a closer look, it was totally logical.