Bug 1371445 - Pre: Produce and upload XML and HTML findbugs reports. r=maliu draft
authorNick Alexander <nalexander@mozilla.com>
Tue, 04 Jul 2017 13:05:20 -0700
changeset 607763 8d48b664903bce32def8f0762a86d31c250c3853
parent 607762 45b1d63374cd9ae4b64c75ca65b2d8b3296f5ac5
child 607764 783c40122a0e50eb62d8b12ccbfc4f8457724e0f
push id68104
push usernalexander@mozilla.com
push dateWed, 12 Jul 2017 21:11:53 +0000
reviewersmaliu
bugs1371445
milestone56.0a1
Bug 1371445 - Pre: Produce and upload XML and HTML findbugs reports. r=maliu We want HTML reports for humans and XML reports for processing. It's unfortunate that we need to handle this manually, but here we are. MozReview-Commit-ID: BKEhl7cInPP
mobile/android/app/build.gradle
taskcluster/ci/android-stuff/kind.yml
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -433,72 +433,107 @@ def makeTaskExecutionListener(artifactRo
                 println "TEST-UNEXPECTED-FAIL | android-lint | Lint found errors in the project; aborting build. See the report at: $url"
                 break
 
             case ':app:testOfficialAustralisDebugUnitTest':
                 def url = "${artifactRootUrl}/public/android/unittest/officialAustralisDebug/index.html"
                 println "TEST-UNEXPECTED-FAIL | android-test | There were failing tests. See the reports at: $url"
                 break
 
-            case ':app:findbugsOfficialAustralisDebug':
+            case ':app:findbugsHtmlOfficialAustralisDebug':
                 def url = "${artifactRootUrl}/public/android/findbugs/findbugs-officialAustralisDebug-output.html"
                 println "TEST-UNEXPECTED-FAIL | android-findbugs | Findbugs found issues in the project. See the report at: $url"
                 break
 
+            case ':app:findbugsXmlOfficialAustralisDebug':
+                def url = "${artifactRootUrl}/public/android/findbugs/findbugs-officialAustralisDebug-output.xml"
+                println "TEST-UNEXPECTED-FAIL | android-findbugs | Findbugs found issues in the project. See the report at: $url"
+                break
+
             case ':app:lintOfficialPhotonDebug':
                 def url = "${artifactRootUrl}/public/android/lint/lint-results-officialPhotonDebug.html"
                 println "TEST-UNEXPECTED-FAIL | android-lint | Lint found errors in the project; aborting build. See the report at: $url"
                 break
 
             case ':app:testOfficialPhotonDebugUnitTest':
                 def url = "${artifactRootUrl}/public/android/unittest/officialPhotonDebug/index.html"
                 println "TEST-UNEXPECTED-FAIL | android-test | There were failing tests. See the reports at: $url"
                 break
 
-            case ':app:findbugsOfficialPhotonDebug':
+            case ':app:findbugsHtmlOfficialPhotonDebug':
                 def url = "${artifactRootUrl}/public/android/findbugs/findbugs-officialPhotonDebug-output.html"
                 println "TEST-UNEXPECTED-FAIL | android-findbugs | Findbugs found issues in the project. See the report at: $url"
                 break
+
+            case ':app:findbugsXmlOfficialPhotonDebug':
+                def url = "${artifactRootUrl}/public/android/findbugs/findbugs-officialPhotonDebug-output.xml"
+                println "TEST-UNEXPECTED-FAIL | android-findbugs | Findbugs found issues in the project. See the report at: $url"
+                break
             }
         }
     }
 }
 
 // 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
+// Bug 1320035: Gradle configuration for running findbugs.  Findbugs only allows
+// to generate one report per invocation: https://stackoverflow.com/a/42720235.
+// Run two tasks, accepting the cost of duplicate work.
 android.applicationVariants.all { variant ->
-    task("findbugs${variant.name.capitalize()}", type: FindBugs) {
-        description "Analyze ${variant.name} code with findbugs"
+    task("findbugsHtml${variant.name.capitalize()}", type: FindBugs) {
+        // TODO: figure out how to share the shared configuration.
+        description "Analyze ${variant.name} code with findbugs (HTML report)"
         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
 
         excludeFilter = file("findbugs-exclude.xml")
+        dependsOn "assemble${variant.name.capitalize()}"
 
         reports {
-            html.enabled = true // We only care about HTML reports for humans
-            xml.enabled = false
-
+            html.enabled = true // HTML reports for humans.
             html.destination = "$project.buildDir/outputs/findbugs/findbugs-${variant.name}-output.html"
+            xml.enabled = false
         }
+    }
+
+    task("findbugsXml${variant.name.capitalize()}", type: FindBugs) {
+        // TODO: figure out how to share the shared configuration.
+        description "Analyze ${variant.name} code with findbugs (XML report)"
+        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
+
+        excludeFilter = file("findbugs-exclude.xml")
         dependsOn "assemble${variant.name.capitalize()}"
+
+        reports {
+            xml.enabled = true // XML reports for machines.
+            xml.destination = "$project.buildDir/outputs/findbugs/findbugs-${variant.name}-output.xml"
+            html.enabled = false
+        }
     }
 }
 
 // Bug 1353055 - Strip 'vars' debugging information to agree with moz.build.
 apply from: "${topsrcdir}/mobile/android/gradle/debug_level.gradle"
 android.applicationVariants.all configureVariantDebugLevel
 
 
--- a/taskcluster/ci/android-stuff/kind.yml
+++ b/taskcluster/ci/android-stuff/kind.yml
@@ -255,19 +255,25 @@ jobs:
                     disable_signing.py
                     platform_supports_post_upload_to_latest.py
                 MOZHARNESS_SCRIPT: "mozharness/scripts/fx_desktop_build.py"
                 TOOLTOOL_MANIFEST: "mobile/android/config/tooltool-manifests/android-frontend/releng.manifest"
             artifacts:
               - name: public/android/findbugs/findbugs-officialAustralisDebug-output.html
                 path: /home/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/app/outputs/findbugs/findbugs-officialAustralisDebug-output.html
                 type: file
+              - name: public/android/findbugs/findbugs-officialAustralisDebug-output.xml
+                path: /home/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/app/outputs/findbugs/findbugs-officialAustralisDebug-output.xml
+                type: file
               - name: public/android/findbugs/findbugs-officialPhotonDebug-output.html
                 path: /home/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/app/outputs/findbugs/findbugs-officialPhotonDebug-output.html
                 type: file
+              - name: public/android/findbugs/findbugs-officialPhotonDebug-output.xml
+                path: /home/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/app/outputs/findbugs/findbugs-officialPhotonDebug-output.xml
+                type: file
               - name: public/build
                 path: /home/worker/artifacts/
                 type: directory
             caches:
               - name: tooltool-cache
                 mount-point: /home/worker/tooltool-cache
                 type: persistent
             relengapi-proxy: true