1

I am now using Android Studio 3.1.3 version. When clicked Build/Clean menu, it delete the build directory.(for example: app/build directory)

By the way, I want to retain the build directory only. On the other hand, I want to delete the sub-directories and files in build directory.

How to modify the "clean" feature in gradle build?

(Because I am using "soft link" of build directory and the real build directory is located in RAMDISK.)

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Star_Man
  • 1,091
  • 1
  • 13
  • 30

1 Answers1

0

Have you considered changing the $buildDir on each project rather than using a soft link? See Project.setBuildDir(File)

Eg

ext {
    ramDiskRoot = 'z:/foo' 
} 
allprojects {
    buildDir = "$ramDiskRoot/$name/build"
}

If you wanted to keep this logic outside of your buildscript you could use an init script

lance-java
  • 25,497
  • 4
  • 59
  • 101
  • I used the init script before. But a lot of errors were found such as "cannot create directory " when using lambda method. Thank you for your answer. – Star_Man Jul 31 '18 at 09:38
  • Possibly using File.mkdir() instead of File.mkdirs() but hard to help without seeing it. Possibly best to open a new question for that – lance-java Jul 31 '18 at 09:59