Run a shell script before a gradle build in Android Studio?

Viewed 1792

Is it possible to run a unix shell script in Android Studio before every (gradle) build?

I'm having some trouble with gradle builds taking forever and one (admittedly bad) solution that works is to kill all java processes if they hold more than say 6Mb memory.

What I would like to do is run a shell script that does that before every build in Android Studio.

I'm not looking to add a gradle task to run before my build. That won't work because if I kill all java processes, gradle will also be killed.

So again: Can I set up Android Studio (or gradlew) to run a script before building?

1 Answers

Instruction for Intellij Idea, but I hope it works for Android Studio

  1. Edit configirations...

enter image description here

  1. Select\create run configuration for gradle build. Add "before launch" option

enter image description here

  1. Select ptoper option. For example - "Run external tool"

enter image description here

Related