Bug 1121622 - Insert omnijar and libraries into debug APK only; Proguard release APK. r=me

DONTBUILD NPOTB

Local developers should only be building debug APKs.  I intend
automation to only build release APKs, and automation will insert the
omnijar and native libraries into the release APK during packaging.

This change requires local developers to delete
$OBJDIR/mobile/android/gradle/app/src/main/{assets,jniLibs}.
This commit is contained in:
Nick Alexander 2015-01-14 11:07:06 -08:00
parent c0ffd036a5
commit 322945eb0d
4 changed files with 33 additions and 29 deletions

View File

@ -5,8 +5,8 @@ apply from: rootProject.file("${topsrcdir}/mobile/android/gradle/android.gradle"
android {
buildTypes {
release {
minifyEnabled false
proguardFile getDefaultProguardFile('proguard-android.txt')
minifyEnabled true
proguardFile "${topsrcdir}/mobile/android/config/proguard/proguard.cfg"
}
}
@ -24,5 +24,31 @@ android {
dependencies {
compile project(':base')
compile project(':omnijar')
androidTestCompile fileTree(dir: 'libs', include: ['*.jar'])
}
/**
* 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')
def generateAssetsTask = tasks.findByName("generate${name.capitalize()}Assets")
generateAssetsTask.dependsOn buildOmnijarTask
}

View File

@ -40,7 +40,6 @@ dependencies {
}
compile project(':branding')
compile project(':omnijar')
compile project(':preprocessed_code')
compile project(':preprocessed_resources')
compile project(':thirdparty')

View File

@ -1,30 +1,12 @@
apply plugin: 'java'
// sourceSets {
// main {
// java {
// // Remove the default directories entirely.
// srcDirs = []
// // Depend on everything in mobile/android that goes into
// // the omnijar.
// srcDir 'src/main/java/locales'
// srcDir 'src/main/java/chrome'
// srcDir 'src/main/java/components'
// srcDir 'src/main/java/modules'
// srcDir 'src/main/java/themes'
// }
// }
// }
/**
* This task runs when any input file is newer than the omnijar.
*/
task rebuildOmnijar(type:Exec) {
// Depend on all the inputs labeled as Java sources.
// project.sourceSets.main.java.srcDirs.each { srcDir ->
// inputs.sourceDir srcDir
// }
task buildOmnijar(type:Exec) {
dependsOn generateCodeAndResources
// Depend on all the Gecko resources.
inputs.sourceDir 'src/main/java/locales'
inputs.sourceDir 'src/main/java/chrome'
inputs.sourceDir 'src/main/java/components'
@ -43,9 +25,6 @@ task rebuildOmnijar(type:Exec) {
args 'gradle-omnijar'
}
// Rebuild the omnijar before the earliest Java task.
tasks.compileJava.dependsOn rebuildOmnijar
apply plugin: 'idea'
idea {

View File

@ -112,8 +112,8 @@ class MachCommands(MachCommandBase):
srcdir('app/build.gradle', 'mobile/android/gradle/app/build.gradle')
objdir('app/src/main/AndroidManifest.xml', 'mobile/android/base/AndroidManifest.xml')
objdir('app/src/main/assets', 'dist/fennec/assets')
objdir('app/src/main/jniLibs', 'dist/fennec/lib')
objdir('app/src/debug/assets', 'dist/fennec/assets')
objdir('app/src/debug/jniLibs', 'dist/fennec/lib')
# Test code.
srcdir('app/src/robocop_harness/org/mozilla/gecko', 'build/mobile/robocop')
srcdir('app/src/robocop/org/mozilla/gecko/tests', 'mobile/android/base/tests')