How to clean buildSrc dir from root project in Gradle?
Asked Answered
D

3

12

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)

Dobrinsky answered 8/8, 2014 at 10:13 Comment(2)
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?Sita
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 buildDobrinsky
D
3

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

Dragone answered 8/8, 2014 at 10:34 Comment(6)
I do not understand why?Dobrinsky
Because buildSrc is a separate and implicit build that finishes before even the configuration phase of the main build starts.Dragone
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.Dobrinsky
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).Dragone
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.Goatfish
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 invalidatedFigurine
S
18

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.

Springlet answered 12/12, 2017 at 23:16 Comment(2)
This does not seem to actually clean buildSrc.Goatfish
@KennKnowles It cleans the build results of the buildSrc project, not the entire buildSrc directory.Springlet
D
3

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

Dragone answered 8/8, 2014 at 10:34 Comment(6)
I do not understand why?Dobrinsky
Because buildSrc is a separate and implicit build that finishes before even the configuration phase of the main build starts.Dragone
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.Dobrinsky
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).Dragone
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.Goatfish
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 invalidatedFigurine
H
0

The meta-build output is right there:

rm -rf buildSrc/build
Hardwood answered 9/5, 2023 at 3:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.