Bug 1457255 - 3. Turn Java warnings into errors; r=nalexander
authorJim Chen <nchen@mozilla.com>
Tue, 01 May 2018 00:22:54 -0400
changeset 472624 1d986592d690a79f122361b5cb1d8b91e08877c0
parent 472623 d8eab86052b640012218606a9e704027cc59ff43
child 472625 3b9cbc054960cd02fcfea9015abb7fdc35ff3a4d
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1457255
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1457255 - 3. Turn Java warnings into errors; r=nalexander Turn Java warnings into errors except for the deprecation and serial warnings. This is done for all Gradle projects except the thirdparty project.
build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -94,17 +94,33 @@ if ('multi' == System.env.AB_CD) {
             if (execResult.exitValue != 0) {
                 throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
             }
         }
     }
 }
 
 afterEvaluate {
-    subprojects {
+    subprojects { project ->
+        if (project.name != 'thirdparty') {
+            tasks.withType(JavaCompile) {
+                // Add compiler args for all code except third-party code.
+                options.compilerArgs += [
+                    // Turn on all warnings, except...
+                    "-Xlint:all",
+                    // Deprecation, because we do use deprecated API for compatibility.
+                    "-Xlint:-deprecation",
+                    // Serial, because we don't use Java serialization.
+                    "-Xlint:-serial",
+                    // Turn all remaining warnings into errors,
+                    // unless marked by @SuppressWarnings.
+                    "-Werror"]
+            }
+        }
+
         if (!hasProperty('android')) {
             return
         }
         android.applicationVariants.all {
             preBuild.dependsOn rootProject.generateCodeAndResources
         }
         android.libraryVariants.all {
             preBuild.dependsOn rootProject.generateCodeAndResources