summaryrefslogtreecommitdiff
path: root/library/self.gradle
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2017-05-04 12:06:00 -0700
committerMaurice Lam <yukl@google.com>2017-05-04 12:06:00 -0700
commit65ad0d1c789d34bedbe39da63627c05144adf335 (patch)
tree5f3abf9f0cad97cb579a5048755cee03b6355fb2 /library/self.gradle
parentc8acb8d45326291ba39f5d75fed18dd412f4fb5f (diff)
downloadsetupwizard-65ad0d1c789d34bedbe39da63627c05144adf335.tar.gz
Support multiple library test APKs
- Extracted the instrumentation test APK generation code to dist-library-instrumentation-tests.gradle, which is enhanced to support multiple test APKs for different build variants, so that the output APK name will not conflict. - Extracted Robolectric test code to dist-unit-tests.gradle so that it can be more easily reused and for better organization. Test: ./gradlew, build_for_build_server.sh builds expected artifacts Change-Id: I7a3c4b3b2c3528fda80deb7778a5af5f7703c913
Diffstat (limited to 'library/self.gradle')
-rw-r--r--library/self.gradle44
1 files changed, 12 insertions, 32 deletions
diff --git a/library/self.gradle b/library/self.gradle
index b7cbd55..6a405e2 100644
--- a/library/self.gradle
+++ b/library/self.gradle
@@ -1,8 +1,10 @@
/**
* This self.gradle build file is only run when built in ub-setupwizard-* branches.
*/
-apply plugin: 'dist'
apply from: 'standalone-rules.gradle'
+apply from: '../tools/gradle/dist-library-instrumentation-tests.gradle'
+apply from: '../tools/gradle/dist-unit-tests.gradle'
+
// Add targets for tests
android.sourceSets {
androidTest {
@@ -62,36 +64,14 @@ android.lintOptions {
android.libraryVariants.all { variant ->
variant.assemble.dependsOn(tasks.findByName('lint'))
}
-def distTask = tasks.findByName('dist')
-if (distTask) {
- // Output all test APKs to the distribution folder
- android.testVariants.all { variant ->
- // Make the dist task depend on the test variant, so the test APK will be built
- distTask.dependsOn variant.assemble
- // TODO: remap the different test variants to different file names
- }
-
- // Output the Robolectric test results to host-test-reports/*.zip
- afterEvaluate {
- android.unitTestVariants.all { variant ->
- def task = tasks.findByName('test' + variant.name.capitalize())
- gradle.taskGraph.whenReady { taskGraph ->
- task.ignoreFailures = taskGraph.hasTask(distTask)
- }
- // Create a zip file of the XML test reports and dist it to host-test-reports.
- // The file path and format should match GradleHostBasedTest class in TradeFed.
- def junitReport = task.reports.junitXml
- if (junitReport.enabled) {
- def zipTask = project.tasks.create("zipResultsOf${task.name.capitalize()}", Zip) {
- from junitReport.destination
- archiveName = task.name + 'Result.zip'
- destinationDir = junitReport.destination.parentFile
- }
- tasks.dist.dependsOn zipTask
- zipTask.mustRunAfter task
- dist.file zipTask.archivePath.path, "host-test-reports/${zipTask.archiveName}"
- }
- }
- }
+// For compatibility with existing continuous test configurations, copy the file to
+// setup-wizard-libTest.apk
+// TODO: Remove this once continuous test configurations are updated to handle the new file name
+task createLegacyTestApk(type: Copy) {
+ from "${project.ext.distDir}/setup-wizard-lib-gingerbreadCompat-debug-androidTest.apk"
+ into "${project.ext.distDir}"
+ rename ('setup-wizard-lib-gingerbreadCompat-debug-androidTest.apk', 'setup-wizard-libTest.apk')
}
+
+tasks.dist.finalizedBy createLegacyTestApk