Bug 1415298 - Fix finding assets/ in |mach android test| locally. r=maliu,nechen draft
authorNick Alexander <nalexander@mozilla.com>
Tue, 07 Nov 2017 12:43:40 -0800
changeset 695259 2e3359a372289593599725e1fa072e365f7c53cc
parent 695258 cfbe845516b0ede33e8c095468589eef30bb62bb
child 739547 5723ff2bab0fece80040d63f73ba87383b352438
push id88368
push usernalexander@mozilla.com
push dateWed, 08 Nov 2017 22:39:54 +0000
reviewersmaliu, nechen
bugs1415298
milestone58.0a1
Bug 1415298 - Fix finding assets/ in |mach android test| locally. r=maliu,nechen Upgrading to the Android-Gradle plugin 3.0+ broke |mach android test| locally. This addresses the issue. MozReview-Commit-ID: 3vV47ET7d19
mobile/android/app/build.gradle
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -562,8 +562,19 @@ android.applicationVariants.all { varian
             filename.replace 'R.txt', "R-${new Date().format('yyyyMMddHHmmssSSS')}.txt"
         }
 
         dependsOn processResourcesTask
     }
 
     assembleTask.dependsOn dumpTask
 }
+
+// Bug 1415298: make Robolectric find assets.  Fix adapted from
+// https://github.com/robolectric/robolectric/issues/2647.
+android.applicationVariants.all { variant ->
+    def productFlavor = ""
+    variant.productFlavors.each {
+        productFlavor += "${it.name.capitalize()}"
+    }
+    def buildType = "${variant.buildType.name.capitalize()}"
+    tasks["compile${productFlavor}${buildType}UnitTestSources"].dependsOn(tasks["merge${productFlavor}${buildType}Assets"])
+}