gecko-dev/mobile/android/app/build.gradle
Nick Alexander e6a9770f2a Bug 938994 - Post: Update Gradle configurations. r=sebastian
I moved the JAR out of the root directory because I didn't want
multiple copies of things in robocop/ appearing in IntelliJ, although
this turns out to not be strictly necessary.  Keeping it as part of a
general push to move things out of the root dumping ground.

--HG--
rename : mobile/android/tests/browser/robocop/robotium-solo-4.3.1.jar => mobile/android/tests/browser/robocop/libs/robotium-solo-4.3.1.jar
extra : commitid : 6NYW1zNU7k8
extra : rebase_source : e152435da39612fdb69749936c713313f2a5b006
extra : histedit_source : aca11a9101156670d49fe89a9237031e4089f2b8
2015-11-09 10:18:45 -08:00

181 lines
5.9 KiB
Groovy

buildDir "${topobjdir}/gradle/build/mobile/android/app"
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
targetSdkVersion 22
minSdkVersion 9
applicationId mozconfig.substs.ANDROID_PACKAGE_NAME
testApplicationId 'org.mozilla.roboexample.test'
testInstrumentationRunner 'org.mozilla.gecko.FennecInstrumentationTestRunner'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled true
proguardFile "${topsrcdir}/mobile/android/config/proguard/proguard.cfg"
}
}
sourceSets {
main {
manifest.srcFile "${topobjdir}/mobile/android/base/AndroidManifest.xml"
}
androidTest {
manifest.srcFile "${topobjdir}/mobile/android/tests/browser/robocop/AndroidManifest.xml"
java {
srcDir "${topsrcdir}/mobile/android/tests/browser/robocop/src"
srcDir "${topsrcdir}/mobile/android/tests/background/junit3/src"
srcDir "${topsrcdir}/mobile/android/tests/browser/junit3/src"
srcDir "${topsrcdir}/mobile/android/tests/javaddons/src"
}
res {
srcDir "${topsrcdir}/mobile/android/tests/browser/robocop/res"
}
assets {
srcDir "${topsrcdir}/mobile/android/tests/browser/robocop/assets"
}
}
}
}
dependencies {
compile project(':base')
// Including the Robotium JAR directly can cause issues with dexing.
androidTestCompile 'com.jayway.android.robotium:robotium-solo:4.3.1'
}
task syncOmnijarFromDistDir(type: Sync) {
into("${project.buildDir}/generated/omnijar")
from("${topobjdir}/dist/fennec/assets") {
include 'omni.ja'
}
}
task checkLibsExistInDistDir<< {
if (syncLibsFromDistDir.source.empty) {
throw new GradleException("Required JNI libraries not found in ${topobjdir}/dist/fennec/lib. Have you built and packaged?")
}
}
task syncLibsFromDistDir(type: Sync, dependsOn: checkLibsExistInDistDir) {
into("${project.buildDir}/generated/jniLibs")
from("${topobjdir}/dist/fennec/lib")
}
task checkAssetsExistInDistDir<< {
if (syncAssetsFromDistDir.source.empty) {
throw new GradleException("Required assets not found in ${topobjdir}/dist/fennec/assets. Have you built and packaged?")
}
}
task syncAssetsFromDistDir(type: Sync, dependsOn: checkAssetsExistInDistDir) {
into("${project.buildDir}/generated/assets")
from("${topobjdir}/dist/fennec/assets") {
exclude 'omni.ja'
}
}
// The omnijar inputs are listed as resource directory inputs to a dummy JAR.
// That arrangement labels them nicely in IntelliJ. See the comment in the
// :omnijar project for more context.
evaluationDependsOn(':omnijar')
task buildOmnijar(type:Exec) {
dependsOn rootProject.generateCodeAndResources
// See comment in :omnijar project regarding interface mismatches here.
inputs.source project(':omnijar').sourceSets.main.resources.srcDirs
// Produce a single output file.
outputs.file "${topobjdir}/dist/fennec/assets/omni.ja"
workingDir "${topobjdir}"
commandLine mozconfig.substs.GMAKE
args '-C'
args "${topobjdir}/mobile/android/base"
args 'gradle-omnijar'
// Only show the output if something went wrong.
ignoreExitValue = true
standardOutput = new ByteArrayOutputStream()
errorOutput = standardOutput
doLast {
if (execResult.exitValue != 0) {
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
}
}
}
android.applicationVariants.all { variant ->
// We only insert omni.ja and the .so libraries into debug builds.
def name = variant.buildType.name
if (!name.contains(com.android.builder.core.BuilderConstants.DEBUG)) {
return
}
syncOmnijarFromDistDir.dependsOn buildOmnijar
def generateAssetsTask = tasks.findByName("generate${name.capitalize()}Assets")
generateAssetsTask.dependsOn syncOmnijarFromDistDir
generateAssetsTask.dependsOn syncLibsFromDistDir
generateAssetsTask.dependsOn syncAssetsFromDistDir
android.sourceSets.debug.assets.srcDir syncOmnijarFromDistDir.destinationDir
android.sourceSets.debug.assets.srcDir syncAssetsFromDistDir.destinationDir
android.sourceSets.debug.jniLibs.srcDir syncLibsFromDistDir.destinationDir
}
apply plugin: 'spoon'
spoon {
// For now, let's be verbose.
debug = true
// It's not helpful to pass when we don't have a device connected.
failIfNoDeviceConnected = true
def spoonPackageName
if (gradle.startParameter.taskNames.contains('runBrowserTests')) {
spoonPackageName = 'org.mozilla.tests.browser.junit3'
}
if (gradle.startParameter.taskNames.contains('runBackgroundTests')) {
spoonPackageName = 'org.mozilla.gecko.background'
}
if (project.hasProperty('spoonPackageName')) {
// Command line overrides everything.
spoonPackageName = project.spoonPackageName
}
if (spoonPackageName) {
instrumentationArgs = ['-e', "package=${spoonPackageName}".toString()]
}
}
// See discussion at https://github.com/stanfy/spoon-gradle-plugin/issues/9.
afterEvaluate {
tasks["spoon${android.testBuildType.capitalize()}AndroidTest"].outputs.upToDateWhen { false }
// This is an awkward way to define different sets of instrumentation tests.
// The task name itself is fished at runtime and the package name configured
// in the spoon configuration.
task runBrowserTests {
dependsOn tasks["spoonDebugAndroidTest"]
}
task runBackgroundTests {
dependsOn tasks["spoonDebugAndroidTest"]
}
}