From 0e47f55c24be28f9d9926a138fd212dd28b66e3f Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Wed, 20 May 2020 19:41:00 -0700 Subject: [PATCH] Only set real BUILD_DATE for non-debug builds This avoids BuildConfig modifications between local dev builds, and speeds up the builds by avoiding running tasks that depend on BuildConfig. Locally, depending on exact build circumstances, this saves about 5% of build runtime for simple code changes, and about 90% of build runtime for no-op builds. --- app/build.gradle | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 87c7b3faa4..6006552f3c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -346,9 +346,13 @@ android.applicationVariants.all { variant -> } def buildDate = Config.generateBuildDate() - buildConfigField 'String', 'BUILD_DATE', '"' + buildDate + '"' - - def variantName = variant.getName() + // Setting buildDate with every build changes the generated BuildConfig, which slows down the + // build. Only do this for non-debug builds, to speed-up builds produced during local development. + if (isDebug) { + buildConfigField 'String', 'BUILD_DATE', '"debug build"' + } else { + buildConfigField 'String', 'BUILD_DATE', '"' + buildDate + '"' + } // ------------------------------------------------------------------------------------------------- // Adjust: Read token from local file if it exists (Only release builds)