From c6e11547449ee6cff1b30ea7e2e2dbbac306b9b1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 19 Sep 2022 15:30:13 +0200 Subject: [PATCH 1/3] Set up gradle doctor plugin --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index d8de6dd55f..193ea43e2e 100644 --- a/build.gradle +++ b/build.gradle @@ -46,6 +46,8 @@ plugins { // Dependency Analysis id 'com.autonomousapps.dependency-analysis' version "1.13.1" + // Gradle doctor + id "com.osacky.doctor" version "0.8.1" } // https://github.com/jeremylong/DependencyCheck From 974ac49594c1f5247749142518b142c65266ca60 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 19 Sep 2022 16:41:00 +0200 Subject: [PATCH 2/3] Add default configuration of Gradle Doctor to the project. Will allow to tweak the configuration if necessary. --- build.gradle | 3 ++ tools/gradle/doctor.gradle | 88 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 tools/gradle/doctor.gradle diff --git a/build.gradle b/build.gradle index 193ea43e2e..f562b40619 100644 --- a/build.gradle +++ b/build.gradle @@ -60,6 +60,9 @@ dependencyCheck { ] } +// Gradle doctor configuration +apply from: './tools/gradle/doctor.gradle' + allprojects { apply plugin: "org.jlleitschuh.gradle.ktlint" apply plugin: "io.gitlab.arturbosch.detekt" diff --git a/tools/gradle/doctor.gradle b/tools/gradle/doctor.gradle new file mode 100644 index 0000000000..af45bdc907 --- /dev/null +++ b/tools/gradle/doctor.gradle @@ -0,0 +1,88 @@ +// Default configuration copied from https://runningcode.github.io/gradle-doctor/configuration/ +doctor { + /** + * Throw an exception when multiple Gradle Daemons are running. + * + * Windows is not supported yet, see https://github.com/runningcode/gradle-doctor/issues/84 + */ + disallowMultipleDaemons = false + /** + * Show a message if the download speed is less than this many megabytes / sec. + */ + downloadSpeedWarningThreshold = 0.5f + /** + * The level at which to warn when a build spends more than this percent garbage collecting. + */ + GCWarningThreshold = 0.10f + /** + * The level at which to fail when a build spends more than this percent garbage collecting. + */ + GCFailThreshold = 0.9f + /** + * Print a warning to the console if we spend more than this amount of time with Dagger annotation processors. + */ + daggerThreshold = 5000 + /** + * By default, Gradle caches test results. This can be dangerous if tests rely on timestamps, dates, or other files + * which are not declared as inputs. + */ + enableTestCaching = true + /** + * By default, Gradle treats empty directories as inputs to compilation tasks. This can cause cache misses. + */ + failOnEmptyDirectories = true + /** + * Do not allow building all apps simultaneously. This is likely not what the user intended. + */ + allowBuildingAllAndroidAppsSimultaneously = false + /** + * Warn if using Android Jetifier. It slows down builds. + */ + warnWhenJetifierEnabled = true + /** + * Negative Avoidance Savings Threshold + * By default the Gradle Doctor will print out a warning when a task is slower to pull from the cache than to + * re-execute. There is some variance in the amount of time a task can take when several tasks are running + * concurrently. In order to account for this there is a threshold you can set. When the difference is above the + * threshold, a warning is displayed. + */ + negativeAvoidanceThreshold = 500 + /** + * Warn when not using parallel GC. Parallel GC is faster for build type tasks and is no longer the default in Java 9+. + */ + warnWhenNotUsingParallelGC = true + /** + * Throws an error when the `Delete` or `clean` task has dependencies. + * If a clean task depends on other tasks, clean can be reordered and made to run after the tasks that would produce + * output. This can lead to build failures or just strangeness with seemingly straightforward builds + * (e.g., gradle clean build). + * http://github.com/gradle/gradle/issues/2488 + */ + disallowCleanTaskDependencies = true + /** + * Warn if using the Kotlin Compiler Daemon Fallback. The fallback is incredibly slow and should be avoided. + * https://youtrack.jetbrains.com/issue/KT-48843 + */ + warnIfKotlinCompileDaemonFallback = true + + /** Configuration properties relating to JAVA_HOME */ + javaHome { + /** + * Ensure that we are using JAVA_HOME to build with this Gradle. + */ + ensureJavaHomeMatches = true + /** + * Ensure we have JAVA_HOME set. + */ + ensureJavaHomeIsSet = true + /** + * Fail on any `JAVA_HOME` issues. + */ + failOnError.set(true) + /** + * Extra message text, if any, to show with the Gradle Doctor message. This is useful if you have a wiki page or + * other instructions that you want to link for developers on your team if they encounter an issue. + */ + extraMessage.set("Here's an extra message to show.") + } +} From 67d899dce44a4b201d550ecd75f566748de1035d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 27 Sep 2022 12:21:02 +0200 Subject: [PATCH 3/3] Deactivate some gradle doctor checks on the CI. --- tools/gradle/doctor.gradle | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/gradle/doctor.gradle b/tools/gradle/doctor.gradle index af45bdc907..c77d2eb338 100644 --- a/tools/gradle/doctor.gradle +++ b/tools/gradle/doctor.gradle @@ -1,4 +1,8 @@ // Default configuration copied from https://runningcode.github.io/gradle-doctor/configuration/ + +def isCiBuild = System.env.BUILDKITE == "true" || System.env.GITHUB_ACTIONS == "true" +println "Is CI build: $isCiBuild" + doctor { /** * Throw an exception when multiple Gradle Daemons are running. @@ -50,7 +54,7 @@ doctor { /** * Warn when not using parallel GC. Parallel GC is faster for build type tasks and is no longer the default in Java 9+. */ - warnWhenNotUsingParallelGC = true + warnWhenNotUsingParallelGC = !isCiBuild /** * Throws an error when the `Delete` or `clean` task has dependencies. * If a clean task depends on other tasks, clean can be reordered and made to run after the tasks that would produce @@ -78,7 +82,7 @@ doctor { /** * Fail on any `JAVA_HOME` issues. */ - failOnError.set(true) + failOnError.set(!isCiBuild) /** * Extra message text, if any, to show with the Gradle Doctor message. This is useful if you have a wiki page or * other instructions that you want to link for developers on your team if they encounter an issue.