Skip to content

Instantly share code, notes, and snippets.

@STAR-ZERO
Created September 5, 2017 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save STAR-ZERO/70c4b3aa477deb8d9521278af8ab70df to your computer and use it in GitHub Desktop.
Save STAR-ZERO/70c4b3aa477deb8d9521278af8ab70df to your computer and use it in GitHub Desktop.
def robolectricDependenciesFolder = project.rootDir.path + "/.robolectric-dependencies"
configurations.create('robolectricRuntime')
dependencies {
robolectricRuntime "org.robolectric:android-all:o-preview-4-robolectric-0"
}
rootProject.task(type: Copy, overwrite: true, "downloadRobolectricDependencies") {
from configurations.robolectricRuntime
into robolectricDependenciesFolder
}
project.afterEvaluate {
tasks.all {
if (it.name.startsWith("test")) {
it.dependsOn(rootProject.tasks.findByName("downloadRobolectricDependencies"))
}
}
}
android {
testOptions {
unitTests.all {
systemProperty 'robolectric.offline', 'true'
systemProperty 'robolectric.dependency.dir', robolectricDependenciesFolder
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment