Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to do out of tree android builds with gradle

One of the most compelling features of cmake is the out-of-tree build paradigm, that enables one to build variants of a project into separate folders thus making it quicker to switch between build configurations.

Is there such a mechanism in android + gradle? Ideally, not a single file would be created or modified in the source tree.

EDIT - What I mean by out of tree is this:

My source folder looks something like:

/work/project/build.gradle
/work/project/src/...
/work/project/res/...       

When I run gradle build, I end up with new folders like:

/work/project/.gradle/...
/work/project/build/..
/work/project/res/...       

I would like to build the project using gradle so that thewe new folders and generated files are in a folder outside of project such as:

/work/build-project/.gradle/...
/work/build-project/build/..
/work/build-project/res/...       

Here's a good find as to the philosphy behind it: http://voices.canonical.com/jussi.pakkanen/2013/04/16/why-you-should-consider-using-separate-build-directories/

like image 949
mritalian Avatar asked Oct 31 '22 13:10

mritalian


1 Answers

You have to add to your root project's build.gradle file:

allprojects {
  buildDir = "/external/path/${rootProject.name}/${project.name}"
}
like image 112
PhilLab Avatar answered Nov 09 '22 09:11

PhilLab