Skip to content

Instantly share code, notes, and snippets.

@luisenricke
Created October 1, 2019 20:20
Show Gist options
  • Save luisenricke/ee476361a401c4504e7f62bc196993cb to your computer and use it in GitHub Desktop.
Save luisenricke/ee476361a401c4504e7f62bc196993cb to your computer and use it in GitHub Desktop.
GradleFasterBuild
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
defaultConfig {
...
//See more in: https://source.android.com/devices/tech/dalvik
multiDexEnabled true
...
}
buildTypes {
...
}
//See more in: https://developer.android.com/studio/build/build-cache.html
dexOptions {
preDexLibraries true
}
}
dependencies {
...
//Don’t use dynamic dependency
//implementation 'androidx.appcompat:appcompat:1.0.+'
//Use static dependency
implementation 'androidx.appcompat:appcompat:1.0.0'
...
}
buildscript {
...
}
plugins{
//id 'com.gradle.build-scan' version '2.4.2' // Uncomment if you want online report for gradle scan
}
/* Uncomment if you want online report for gradle scan
buildScan {
// Build scans are a persistent, shareable record of what happened when running a build. With build scans, you gain deep insights about your build to identify and fix performance bottlenecks.
// https://docs.gradle.com/build-scan-plugin/
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
*/
allprojects {
...
}
...
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# https://developer.android.com/studio/build
# ---------------------------------------- Gradle ---------------------------------------- #
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# https://guides.gradle.org/performance/#adjust_the_daemon_s_heap_size
# https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When set to true, Gradle will reuse task outputs from any previous build, when possible, resulting is much faster builds.
# https://docs.gradle.org/current/userguide/build_cache.html#build_cache
org.gradle.caching=true
# Daemon is a mechanism for improving the performance of Gradle.
# Its enabled by default. Generally its safe to leave the daemon on
# https://guides.gradle.org/performance/#daemon
org.gradle.daemon=true
# Enables incubating configuration on demand, where Gradle will attempt to configure only necessary projects.
# https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects(more than one project).
# https://guides.gradle.org/performance/#parallel_execution
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# ---------------------------------------- Android ---------------------------------------- #
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# The build cache stores certain outputs that the Android plugin for Gradle generates when building your project (such as unpackaged AARs and pre-dexed remote dependencies). Your clean builds are much faster while using the cache because the build system can simply reuse those cached files during subsequent builds, instead of recreating them.
# https://developer.android.com/studio/build/build-cache
android.enableBuildCache=true
# [experimental and unsupported] Android Gradle plugin executes all annotation processors in a separate task and allows the Java compilation task to run incrementally.
# https://developer.android.com/studio/build/optimize-your-build#annotation_processors
# android.enableSeparateAnnotationProcessing = true
# ---------------------------------------- Kotlin ---------------------------------------- #
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Incremental compilation tracks changes of source files between builds so only files affected by these changes would be compiled.
# https://kotlinlang.org/docs/reference/using-gradle.html#incremental-compilation
# https://kotlinlang.org/docs/reference/kapt.html#incremental-annotation-processing-since-1330
kotlin.caching.enabled=true
kotlin.incremental=true
kotlin.incremental.js=true
kapt.incremental.apt=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment