forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1219846 - Part 1: Add 'app' Gradle project in srcdir. r=me
DONTBUILD NPOTB
- Loading branch information
Showing
2 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
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}/build/mobile/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}/build/mobile/robocop/res" | ||
} | ||
assets { | ||
srcDir "${topsrcdir}/mobile/android/tests/browser/robocop/assets" | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile project(':base') | ||
compile project(':omnijar') | ||
// 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' | ||
} | ||
} | ||
|
||
/** | ||
* We want to expose the JSM files and chrome content to IDEs; the omnijar | ||
* project does this. In addition, the :omnijar:buildOmnijar task builds a new | ||
* omni.ja (directly into the object directory). | ||
* | ||
* The task dependency is: :generateDebugAssets -> :omnijar:buildOmnijar. | ||
* | ||
* One might expect that we could do this all in the omnijar project, but there | ||
* appears to be a bug (which I have not fully isolated) where-by debug-only | ||
* assets in a library (.aar file) are ignored in favor of release assets. This | ||
* means we would have to insert the omni.ja into the omnijar project's release | ||
* assets, which is altogether confusing. | ||
*/ | ||
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 | ||
} | ||
|
||
def buildOmnijarTask = project(':omnijar').tasks.getByName('buildOmnijar') | ||
syncOmnijarFromDistDir.dependsOn buildOmnijarTask | ||
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"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters