From 4b77b8d31441697f01fe7ee1f9add16f8a60a253 Mon Sep 17 00:00:00 2001 From: marcin_bak Date: Tue, 27 Jun 2017 11:52:15 +0200 Subject: [PATCH 1/3] Added support for apk splits --- src/main/groovy/com/stanfy/spoon/gradle/SpoonExtension.groovy | 4 ++++ src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/stanfy/spoon/gradle/SpoonExtension.groovy b/src/main/groovy/com/stanfy/spoon/gradle/SpoonExtension.groovy index fc74a45..b53552f 100644 --- a/src/main/groovy/com/stanfy/spoon/gradle/SpoonExtension.groovy +++ b/src/main/groovy/com/stanfy/spoon/gradle/SpoonExtension.groovy @@ -56,4 +56,8 @@ class SpoonExtension { /** Grants all permisions for Android M >= devices */ boolean grantAllPermissions + + /** Define build variant to be used for testing (ex. testVariant = "x86Screenshot"). Useful when working with apk splits **/ + String testVariant + } diff --git a/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy b/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy index 9a90a4f..76a2cd7 100644 --- a/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy +++ b/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy @@ -94,7 +94,9 @@ class SpoonPlugin implements Plugin { throw new UnsupportedOperationException("Spoon plugin for gradle currently does not support abi/density splits for test apks") } SpoonExtension config = project.spoon - return testVariant.testedVariant.outputs.collect { def projectOutput -> + return testVariant.testedVariant.outputs.findAll { def projectOutput -> + config.testVariant.isEmpty() || (projectOutput.getName() == config.testVariant) + }.collect { def projectOutput -> SpoonRunTask task = project.tasks.create("${TASK_PREFIX}${testVariant.name.capitalize()}${suffix}", SpoonRunTask) task.configure { group = JavaBasePlugin.VERIFICATION_GROUP From 5c6994ca99d0219b8aad38eb79ac398ee9466e1c Mon Sep 17 00:00:00 2001 From: marcin_bak Date: Tue, 27 Jun 2017 12:00:07 +0200 Subject: [PATCH 2/3] Added README documentation of parameter --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0040075..2dec70a 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ spoon { // To grant permissions to Android M >= devices */ grantAllPermissions = true + + // Define build variant to be used for testing. Useful when working with apk splits */ + testVariant = "x86Screenshot" } ``` From 080482dad44b824a8d6444381537d48b0957a283 Mon Sep 17 00:00:00 2001 From: marcin_bak Date: Tue, 27 Jun 2017 12:38:07 +0200 Subject: [PATCH 3/3] Fix nullpointer when parameter is not defined --- .../groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy b/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy index 76a2cd7..90cf417 100644 --- a/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy +++ b/src/main/groovy/com/stanfy/spoon/gradle/SpoonPlugin.groovy @@ -94,9 +94,11 @@ class SpoonPlugin implements Plugin { throw new UnsupportedOperationException("Spoon plugin for gradle currently does not support abi/density splits for test apks") } SpoonExtension config = project.spoon - return testVariant.testedVariant.outputs.findAll { def projectOutput -> - config.testVariant.isEmpty() || (projectOutput.getName() == config.testVariant) - }.collect { def projectOutput -> + return testVariant.testedVariant.outputs + .findAll { def projectOutput -> + config.testVariant == null || config.testVariant.isEmpty() || (projectOutput.getName() == config.testVariant) + } + .collect { def projectOutput -> SpoonRunTask task = project.tasks.create("${TASK_PREFIX}${testVariant.name.capitalize()}${suffix}", SpoonRunTask) task.configure { group = JavaBasePlugin.VERIFICATION_GROUP