Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clean buildSrc dir from root project in Gradle?

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)

like image 272
Xelian Avatar asked Aug 08 '14 10:08

Xelian


People also ask

How do I stop Gradle from using buildsrc?

Stop using Gradle buildSrc. Use composite builds instead You are invalidating the whole project for any change within buildSrc, usually without there being a valid reason. We can keep the sweetness of Kotlin whilst avoiding this. buildSrc is a directory at the Gradle project root, which can contain our build logic.

What is the default location of a Gradle project?

The default is the .gradle directory in the user’s home directory. Specifies the start directory for Gradle. Defaults to current directory. Specifies the project-specific cache directory. Default value is .gradle in the root project directory. Sets a system property of the JVM, for example -Dmyprop=myvalue. See System Properties.

Should I use Gradle buildsrc or composite builds?

Use composite builds instead | by Josef Raska | ProAndroidDev Stop using Gradle buildSrc. Use composite builds instead You are invalidating the whole project for any change within buildSrc, usually without there being a valid reason. We can keep the sweetness of Kotlin whilst avoiding this.

How do I run a Gradle task for all subprojects?

You can also run a task for all subprojects by again using a task selector that consists of the task name only. For example, this will run the "test" task for all subprojects when invoked from the root project directory: When invoking Gradle from within a subproject, the project name should be omitted:


1 Answers

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.

like image 53
Ilya Avatar answered Oct 15 '22 21:10

Ilya