3

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.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Simon Schiller
  • 644
  • 1
  • 8
  • 23
  • May you will find it helpful: https://stackoverflow.com/questions/28272344/gradle-exclude-a-specific-subproject-from-full-build ? – Opal Aug 22 '17 at 06:40

1 Answers1

5

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.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841