Reputation: 3972
I have the following multi-project setup in Gradle for building multiple Android apps which use a few libraries:
Let's say my root dir is /workspace
The directory structure is the following (it's incomplete):
/workspace/ --> root dir for the gradle build
/workspace/settings.gradle
...
/workspace/myapp1/Android/ --> contains the 1st app (has a build.gradle)
/workspace/myapp2/Android/ --> contains the 2nd app (has a build.gradle)
...
/market_licensing/library/ ---> contains a lib (has a build.gradle)
/play_apk_expansion/downloader_library/ ---> another lib (has a build.gradle)
settings.gradle
in /workspace/ looks like this:
include ':market_licensing:library'
include ':play_apk_expansion:downloader_library'
include ':myapp1:Android'
include ':myapp2:Android'
When I run a gradle build in one of the app directories, it works:
For example, /workspace/myapp1/Android>gradle clean
runs fine.
However, this will EVALUATE also the build.gradle project for myapp2
.
This is expected according to the Gradle manual. In http://www.gradle.org/docs/current/userguide/multi_project_builds.html, in part 56.3. Execution rules for multi-project builds
it says "Gradle always evaluates every project of the multi-project build and creates all existing task objects.".
My problem with this is that this slows down my builds unnecessarily. Unnecessarily because, when I'm building myapp1
, I don't care about myapp2
. I want the libraries to be in a good state, but I don't care about myapp2
. This is not terrible for 2 apps, but imagine having 20 apps. I want to be able to build the app that I'm currently working on as fast as possible.
Is there a way to ignore other subprojects , even for the evaluation stage? Or is there an alternative way to set up multiple projects that depend on the same libraries but don't depend on each other?
Upvotes: 4
Views: 2779
Reputation: 28653
as you pointed out the default behaviour in gradle is to evaluate all projects. There are plans (and also initial work started) to make this more fine grained in the future. For now you might checkout the incubating feature "configuration on demand". Maybe this helps you. have a look at http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:cross_project_configuration for details
cheers,
René
Upvotes: 3