Last active
August 29, 2015 14:07
-
-
Save loeschg/3ce24c34dec364270ab8 to your computer and use it in GitHub Desktop.
Revisions
-
loeschg revised this gist
Nov 21, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def excludeEspressoFilesIfNecessary(theTask) { // Exclude espresso and add the task as a dependency. project.task(cleanupTaskName) << { def FileTree tree = fileTree(dir: TEST_SRC_DIR) tree.exclude TO_EXCLUDE theTask.source = tree } -
loeschg revised this gist
Oct 7, 2014 . 1 changed file with 10 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,17 +13,22 @@ tasks.whenTaskAdded { theTask -> * Android Testing. (╯°□°)╯︵ ┻━┻ */ def excludeEspressoFilesIfNecessary(theTask) { // Modify these if needed. def final TEST_SRC_DIR = 'src/test/java' def final TO_EXCLUDE = '**/espresso/**/*.java' def final compileTestPattern= /compileTest([^ ]*)Java/ if (theTask.name.matches(compileTestPattern)) { // find all task names. // Grabs the name of the variant to use when naming the new task. def matcher = (theTask.name =~ compileTestPattern) def cleanupTaskName = "touchUp${matcher[0][1]}RobolectricSourceSet" // Exclude espresso and add the task as a dependency. project.task(cleanupTaskName) << { FileTree tree = fileTree(dir: TEST_SRC_DIR) tree.exclude TO_EXCLUDE theTask.source = tree } theTask.dependsOn(cleanupTaskName) -
loeschg revised this gist
Oct 7, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ /** Hook into existing tasks. */ tasks.whenTaskAdded { theTask -> excludeEspressoFilesIfNecessary(theTask) } /** @@ -12,7 +12,7 @@ tasks.whenTaskAdded { theTask -> * * Android Testing. (╯°□°)╯︵ ┻━┻ */ def excludeEspressoFilesIfNecessary(theTask) { def compileTestPattern= /compileTest([^ ]*)Java/ if (theTask.name.matches(compileTestPattern)) { // find all task names. -
loeschg revised this gist
Oct 7, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ /** Hook into existing tasks. */ tasks.whenTaskAdded { theTask -> checkAndExcludeEspressoFilesFromTask(theTask) } /** @@ -12,7 +12,7 @@ tasks.whenTaskAdded { theTask -> * * Android Testing. (╯°□°)╯︵ ┻━┻ */ def checkAndExcludeEspressoFilesFromTask(theTask) { def compileTestPattern= /compileTest([^ ]*)Java/ if (theTask.name.matches(compileTestPattern)) { // find all task names. -
loeschg revised this gist
Oct 7, 2014 . No changes.There are no files selected for viewing
-
loeschg revised this gist
Oct 7, 2014 . No changes.There are no files selected for viewing
-
loeschg revised this gist
Oct 7, 2014 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,15 +10,17 @@ tasks.whenTaskAdded { theTask -> * normally unless doing this. Double-espresso is used to fix a conflicting Dagger 1.2 dependency * with Espresso. * * Android Testing. (╯°□°)╯︵ ┻━┻ */ def excludeEspressoFilesFromTask(theTask) { def compileTestPattern= /compileTest([^ ]*)Java/ if (theTask.name.matches(compileTestPattern)) { // find all task names. // Grabs the name of the variant to use when naming the new task. def matcher = (theTask.name =~ compileTestPattern) def cleanupTaskName = "touchUp${matcher[0][1]}RobolectricSourceSet" // Exclude espresso and add the task as a dependency. project.task(cleanupTaskName) << { FileTree tree = fileTree(dir: 'src/test/java') tree.exclude '**/espresso/**/*.java' -
loeschg created this gist
Oct 7, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ /** Hook into existing tasks. */ tasks.whenTaskAdded { theTask -> excludeEspressoFilesFromTask(theTask) } /** * This excludes Espresso tests from Robolectric. http://stackoverflow.com/a/24706452/413254 * * This was needed when using double-espresso. I couldn't get Robolectric to exclude them * normally unless doing this. Double-espresso is used to fix a conflicting Dagger 1.2 dependency * with Espresso. * * Android Testing. It's a mess. (╯°□°)╯︵ ┻━┻ */ def excludeEspressoFilesFromTask(theTask) { def tasks = ['compileTestStagingDebugJava', 'compileTestProdDebugJava'] if (tasks.contains(theTask.name.toString())) { def variantPattern = /compileTest(.*)Java/ def matcher = (theTask.name =~ variantPattern) def cleanupTaskName = "touchUp${matcher[0][1]}RobolectricSourceSet" project.task(cleanupTaskName) << { FileTree tree = fileTree(dir: 'src/test/java') tree.exclude '**/espresso/**/*.java' theTask.source = tree } theTask.dependsOn(cleanupTaskName) } }