Exclude configuration from project


(Pavel Dudka) #1

I am trying to create a plugin which can exclude specific configuration from the project and I have a few questions.

Let’s say I have a project with following configurations:

compile:
    |--dep1
    |--dep2
    |--dep3
test:
    |--test_dep1
    |--test_dep2
    |--test_dep3

So when I want to build such project, all dependencies for all configuration will be downloaded.
And this is what I want to change.

I want to be able to exclude test configuration from given project, so test dependencies are not downloaded.

My first attempt was to try to remove test configuration from configurations container, but in this case project fails during evaluation stage.

So the ultimate goal is to make it possible to build project w/o downloading dependencies for specific configuration


(Stefan Oehme) #2

Only dependencies for configurations that are used are downloaded. If you don’t run the tests then the test dependencies aren’t downloaded.

If you run the tests then you obviously need their dependencies, otherwise they wouldn’t work.


(Pavel Dudka) #3

Hm… that’s not what Im seeing actually. Even if I don’t run tests, Gradle still complains that Im missing those dependencies.

But it might actually be the Android Gradle plugin problem (yes, this is an Android project)…


(Stefan Oehme) #4

Indeed, the Android plugin resolves all dependencies at configuration time. The Android team is working on a fix for that. In the meantime you could use this workaround to get rid of dependencies:

configurations.testCompile.dependencies.all { dep ->
  configurations.testCompile.exclude group: dep.group, module: dep.name
}

This excludes all dependencies as soon as they are added to the configuration.


(Pavel Dudka) #5

Aha, thanks a lot! Do you have a bug reference by any chance, so I can subscribe to updates?


(Stefan Oehme) #6

You can follow the 2.3-alpha releases, they are making plenty of great performance improvements and resolving dependencies later will be part of that.