Bug 1371445 - Pre: Fail unit tests if unlimited strength JCE is not installed. r=maliu
This has been a problem as far back as the android-sync repository --
https://github.com/mozilla-services/android-sync#download-prerequisites!
MozReview-Commit-ID: dIWI8WtHKu
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -474,16 +474,27 @@ 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))
}
+if (gradle.startParameter.taskNames.any { it.endsWith('UnitTest') }) {
+ // Approach cribbed from https://github.com/rwinch/jce-checker.
+ int maxKeyLen = javax.crypto.Cipher.getMaxAllowedKeyLength("AES")
+ if (maxKeyLen <= 128) {
+ throw new GradleException(
+ "Android unit tests require " +
+ "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy, see " +
+ "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html")
+ }
+}
+
// 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("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"