Simon Schiller
Simon Schiller

Reputation: 664

Gradle disable the build of dependency projects

I have a a multi-project gradle project (Android) with following structure:

root
|-projA
|-projB
|-projC
|-...

In my specific case, projA is an app which uses projB (module). When I run build on projA, projB also gets built. I need to perform an action only on the project that was originally built (the project where the original action was performed on).

For this purpose I need to somehow get the name/path of this project. I need to do this in the afterEvaluate step if this matters.

Example:

gradlew :projA:build   // Builds A and B     ->  I want only "projA"
gradlew :projB:build   // Builds B           ->  I want "projB"
gradlew :projC:build   // Builds A, B and C  ->  I want only "projC"

I am not sure how I can achive this, I hope someone of you can help me.

Upvotes: 3

Views: 1532

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364808

You can check the official doc:

The standard project dependencies are supported and makes relevant projects configured. If project A has a compile dependency on project B then building A causes configuration of both projects.

However you can disable the build of dependency projects (but pay attention!)

If you don't want depended on projects to be built when doing a partial build. To disable the build of the depended on projects you can run Gradle with the -a option.

Example:

gradle -a :projA:build

From the doc:

-a, --no-rebuild

Do not rebuild project dependencies.

Upvotes: 5

Related Questions