Bug 1320035 - Add gradle configuration for running findbugs. r=maliu
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 24 Nov 2016 11:13:54 +0100
changeset 324299 e84ab1f4e44f266d0597c768414dfccd8b160b12
parent 324298 f05afddd1179c674476af7db84e5714c5f81843a
child 324300 c4d075822fbfd1a2e07b93bdb70edd3596d02139
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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