Skip to content

Instantly share code, notes, and snippets.

@sschuberth
Forked from artem-zinnatullin/build.gradle
Last active August 29, 2015 14:06
Show Gist options
  • Save sschuberth/b3f10b4fa42912153fb1 to your computer and use it in GitHub Desktop.
Save sschuberth/b3f10b4fa42912153fb1 to your computer and use it in GitHub Desktop.
// add this to the general build.gradle, not in the subproject's build.gradle
// improved version of Xavier's tip http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance.
// usage example default, preDex will be enabled: gradle clean build
// usage example disabling preDex: gradle clean build -PpreDexEnable=false
// preDexEnable parameter's value can be set as property of Continuous Integration build config
// this is the main difference from Xavier's workaround where he doing only hasProperty check
project.ext {
project.ext.preDexLibs = !'false'.equals(project.properties['preDexEnable'])
}
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ('com.android.build.gradle.AppPlugin'.equals(plugin.class.name)
|| 'com.android.build.gradle.LibraryPlugin'.equals(plugin.class.name)) {
android {
dexOptions {
javaMaxHeapSize = '4g'
preDexLibraries = rootProject.ext.preDexLibs
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment