Just for completeness, here's how I configured Gradle (and thereby also Android Studio) on Ubuntu 14.04 to always build to RAM disk:
My ~/.bashrc contains this line in the end:
. ~/bin/mkramdisk # Setup personal RAM disk on login.
My ~/bin/mkramdisk is listed below. I suppose you could omit this script and simply use e.g. /dev/shm/${System.env.USER}/gradle-buildsin the following step, but I like having a general RAM disk for other purposes as well and I even use it as $TMP so here goes:
# Setup personal RAM disk.
# This script should be sourced, hence the missing +x flag.
# Source it from e.g. from ~/.bashrc or run it from crontab
# at @reboot event (doesn't work with encrypted homedir btw.)
export RAMDISK=$HOME/tmp/ramdisk
if [ ! -d $RAMDISK ]; then
[ -d /dev/shm/$USER-ramdisk ] || install -vd /dev/shm/$USER-ramdisk -o $USER -m 700
[ -d ~/tmp ] || mkdir -v ~/tmp
[ -L ~/tmp/ramdisk ] || ln -vs /dev/shm/$USER-ramdisk ~/tmp/ramdisk
fi
export TMP=$RAMDISK
NOTE to Macintosh users: It seems you can modify mkramdisk to instead contain this command to make it work on your system.
My ~/.gradle/init.gradle is this (remove debug println statements as you see fit):
println "Loaded personal ~/.gradle/init.gradle"
gradle.projectsLoaded {
rootProject.allprojects {
buildDir = "${System.env.RAMDISK}/gradle-build/${rootProject.name}/${project.name}"
println "BUILDING TO RAMDISK: buildDir=$buildDir"
}
}
in root
build.gradle
See also
and docs https://gradle.org/docs/current/userguide/writing_build_scripts.html
Just for completeness, here's how I configured Gradle (and thereby also Android Studio) on Ubuntu 14.04 to always build to RAM disk:
My
~/.bashrc
contains this line in the end:My
~/bin/mkramdisk
is listed below. I suppose you could omit this script and simply use e.g./dev/shm/${System.env.USER}/gradle-builds
in the following step, but I like having a general RAM disk for other purposes as well and I even use it as$TMP
so here goes:NOTE to Macintosh users: It seems you can modify
mkramdisk
to instead contain this command to make it work on your system.My
~/.gradle/init.gradle
is this (remove debugprintln
statements as you see fit):