11

I have multiproject build in the buildSrc dir.

  buildSrc
       ---build
       ---  subProject1
          ----build (2)
       ---  subProject2
           ----build (3)
       ---  subProject3
          ----build  (4)
       ---  subProject4
          ----build  (5)
    config
    gradle
    src
    build (1)

When I am in the root dir of my project I write:

gradle clean

but only build dir of the root project was deleted(marked with 1). How to trigger Gradle to delete all build directories prom buildSrc without to go manually to buildSrc and to write gradle clean.(marked with 2,3,4,5)

Xelian
  • 16,680
  • 25
  • 99
  • 152
  • What version of `gradle` do you use? Do you have `settings.gradle` in you root dir, where you `include` all your subprojects to the root project? – ivstas Aug 08 '14 at 10:16
  • Gradle 2.0. Yes I have settings.gradle and in the build script I have runtime subprojects.collect { owner.project(it.path) }. Because my buildSrc project is multi-project build – Xelian Aug 08 '14 at 10:29

3 Answers3

17

Since buildSrc is just a gradle project, you can start gradle in buildSrc folder with clean task specified using -p gradle option:

./gradlew -p buildSrc clean

Unfortunately it still requires another gradle invocation before your main build.

Ilya
  • 21,871
  • 8
  • 73
  • 92
2

There is no way to do this (but you shouldn't ever have to clean buildSrc).

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • 2
    I do not understand why? – Xelian Aug 08 '14 at 10:53
  • 1
    Because `buildSrc` is a separate and implicit build that finishes before even the configuration phase of the main build starts. – Peter Niederwieser Aug 08 '14 at 11:04
  • 2
    Ok but Gradle can clean it automatically or with some system property cleanBuildSrc =true to specify the intention of the user this can be done or I am wrong. – Xelian Aug 08 '14 at 11:41
  • 1
    Always cleaning `buildSrc` is possible, but doesn't make sense. I'm not aware of any way to clean `buildSrc` depending on what system property etc. is passed on the command line. Instead, I'd focus on eliminating the need to ever clean `buildSrc` (it shouldn't ever be needed). – Peter Niederwieser Aug 08 '14 at 12:13
  • 2
    Gradle does not consider results dirty when you modify a `build.gradle` even though the rigorous thing to do is consider all results dirty. This is a time that you may wish to clean. – Kenn Knowles Jun 20 '18 at 18:16
  • When there is a big in your compiler and your buildSrc build head an error after updating to a compiler with a fix it would be very very nice to have buildSrc build invalidated – Scott Tiger Jun 12 '23 at 13:48
0

The meta-build output is right there:

rm -rf buildSrc/build
F. P. Freely
  • 1,026
  • 14
  • 24