Bug 1320035 - Add gradle configuration for running findbugs. r?maliu draft
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 24 Nov 2016 11:13:54 +0100
changeset 443619 d3cfbfba8e91054fe376a3f2c67704fd12aca040
parent 443602 bad312aefb42982f492ad2cf36f4c6c3d698f4f7
child 443620 8bf216b53991116c98dcb59afe32a8650f63afae
child 443625 d21fa475c3610f35abc4b40cf117598a8853f982
push id37037
push users.kaspari@gmail.com
push dateThu, 24 Nov 2016 18:41:03 +0000
reviewersmaliu
bugs1320035
milestone53.0a1
Bug 1320035 - Add gradle configuration for running findbugs. r?maliu MozReview-Commit-ID: JATeS3zcvys
mobile/android/app/build.gradle
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -1,14 +1,15 @@
 buildDir "${topobjdir}/gradle/build/mobile/android/app"
 
 apply plugin: 'android-sdk-manager' // Must come before 'com.android.*'.
 apply plugin: 'com.android.application'
 apply plugin: 'checkstyle'
 apply plugin: 'com.getkeepsafe.dexcount'
+apply plugin: 'findbugs'
 
 dexcount {
     format = "tree"
 }
 
 android {
     compileSdkVersion 23
     buildToolsVersion mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION
@@ -409,8 +410,34 @@ def makeTaskExecutionListener(artifactRo
 }
 
 // TASK_ID and RUN_ID are provided by docker-worker; see
 // https://docs.taskcluster.net/manual/execution/workers/docker-worker.
 if (System.env.TASK_ID && System.env.RUN_ID) {
     def artifactRootUrl = "https://queue.taskcluster.net/v1/task/${System.env.TASK_ID}/runs/${System.env.RUN_ID}/artifacts"
     gradle.addListener(makeTaskExecutionListener(artifactRootUrl))
 }
+
+// Bug 1320035: Gradle configuration for running findbugs
+android.applicationVariants.all { variant ->
+    task("findbugs${variant.name.capitalize()}", type: FindBugs) {
+        description "Analyze ${variant.name} code with findbugs"
+        group "Verification"
+
+        ignoreFailures = false // We want builds to fail when running this task and issues are found
+        effort = "max"         // Using more memory and time to find issues is acceptable in automation
+        reportLevel = "high"   // For now we only care about high priority bugs. After we have fixed
+                               // the issues with medium/low priority we can lower the report level here.
+
+        classes = files("$project.buildDir/intermediates/classes")
+        source = variant.javaCompile.source
+        classpath = variant.javaCompile.classpath
+
+        reports {
+            html.enabled = true // We only care about HTML reports for humans
+            xml.enabled = false
+
+            html.destination = "$project.buildDir/outputs/findbugs/findbugs-${variant.name}-output.html"
+        }
+
+        dependsOn "assemble${variant.name.capitalize()}"
+    }
+}
\ No newline at end of file