Created
October 13, 2017 23:19
-
-
Save MoshDev/8c188a5e518fb1a396d78bea42f0e857 to your computer and use it in GitHub Desktop.
This file contains 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 characters
project.afterEvaluate { | |
android.applicationVariants.all { variant -> | |
task "installRun${variant.name.capitalize()}"(type: Exec, dependsOn: "install${variant.name.capitalize()}", group: "run") { | |
commandLine = ["adb", "shell", "monkey", "-p", variant.applicationId + " 1"] | |
doLast { | |
println "Launching ${variant.applicationId}" | |
} | |
} | |
} | |
} | |
def getCurrentVariantTask() { | |
def xml = new XmlParser().parse(project.file("${project.name}.iml")) | |
def selectedBuildVariant = xml.depthFirst().find { node -> | |
node.hasProperty("name") && node.@name == 'SELECTED_BUILD_VARIANT' | |
}?.@value | |
def taskName = "assemble${selectedBuildVariant.capitalize()}" | |
println "task to be executed: $taskName" | |
return taskName | |
} | |
task assembleMe(dependsOn: getCurrentVariantTask()) << {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment