Bug 1104855 - Don't rebuild the omnijar on every Gradle build. rs=margaret

This ticket splits a new omnijar project off of base.  The new
project's omnijar task knows the inputs (well, those under
mobile/android) and the omni.ja output and only re-packages the
omnijar when the task's output is out of date.

With this modification, local building and most importantly the
Android JUnit test cycle is much improved, because the APK is not
re-deployed when only test code is modified.

In addition, the new project lists the omnijar inputs as "Java" source
directories.  Previously, they were listed as "Java resource" source
directories, which meant that the omnijar inputs were packaged into
the final APK.  This wasted time and space.

--HG--
extra : rebase_source : 12c94fdfbee9b7c319d5cfb4d7faad254e90abfc
This commit is contained in:
Nick Alexander 2014-11-25 09:54:31 -08:00
parent bdfaf9c1a6
commit c76981cf16
7 changed files with 61 additions and 20 deletions

View File

@ -422,10 +422,11 @@ $(abspath $(DIST)/fennec/$(OMNIJAR_NAME)): FORCE
$(RM) $(DIST)/fennec/$(notdir $(OMNIJAR_NAME))
# Targets built very early during a Gradle build.
gradle-targets: $(abspath $(DIST)/fennec/$(OMNIJAR_NAME))
gradle-targets: .aapt.deps
.PHONY: gradle-targets
gradle-omnijar: $(abspath $(DIST)/fennec/$(OMNIJAR_NAME))
.PHONY: gradle-targets gradle-omnijar
libs:: geckoview_resources.zip classes.dex jni-stubs.inc GeneratedJNIWrappers.cpp fennec_ids.txt
$(INSTALL) geckoview_resources.zip $(FINAL_TARGET)

View File

@ -61,29 +61,22 @@ android {
srcDir "crashreporter/res"
}
}
resources {
srcDir '../locales'
srcDir '../chrome'
srcDir '../components'
srcDir '../modules'
srcDir '../app'
srcDir '../themes/core'
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':thirdparty')
compile 'com.android.support:support-v4:19.1.+'
compile 'com.android.support:appcompat-v7:19.1.+'
compile 'com.android.support:mediarouter-v7:19.1.+'
compile 'com.google.android.gms:play-services:5.+'
compile project(':thirdparty')
compile project(':omnijar')
}
task prepareObjDir(type:Exec) {
task generateCodeAndResources(type:Exec) {
workingDir "${topobjdir}"
commandLine "${topsrcdir}/mach"
@ -94,5 +87,5 @@ task prepareObjDir(type:Exec) {
}
android.libraryVariants.all { variant ->
variant.checkManifest.dependsOn prepareObjDir
variant.checkManifest.dependsOn generateCodeAndResources
}

View File

@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Tue Nov 25 10:01:42 PST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip

View File

@ -0,0 +1,42 @@
project.buildDir = "${topobjdir}/mobile/android/gradle/omnijar/build"
apply plugin: 'java'
sourceSets {
main {
java {
// Remove the default directories entirely.
srcDirs = []
// Depend on everything in mobile/android that goes into
// the omnijar.
srcDir '../../locales'
srcDir '../../chrome'
srcDir '../../components'
srcDir '../../modules'
srcDir '../../themes/core'
}
}
}
/**
* 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
}
// Produce a single output file.
outputs.file "${topobjdir}/dist/fennec/assets/omni.ja"
workingDir "${topobjdir}"
commandLine "${topsrcdir}/mach"
args 'build'
args '-C'
args 'mobile/android/base'
args 'gradle-omnijar'
}
// Rebuild the omnijar before the earliest Java task.
tasks.compileJava.dependsOn rebuildOmnijar

View File

@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mozilla.gecko.omnijar">
</manifest>

View File

@ -1,8 +1,9 @@
include ':app'
project(':app').projectDir = new File("${topsrcdir}/mobile/android/app")
include ':base'
project(':base').projectDir = new File("${topsrcdir}/mobile/android/base")
include ':omnijar'
include ':thirdparty'
project(':app').projectDir = new File("${topsrcdir}/mobile/android/app")
project(':base').projectDir = new File("${topsrcdir}/mobile/android/base")
project(':omnijar').projectDir = new File("${topsrcdir}/mobile/android/gradle/omnijar")
project(':thirdparty').projectDir = new File("${topsrcdir}/mobile/android/thirdparty")