-
-
Save glombard/cf17025b78b8866ad26c to your computer and use it in GitHub Desktop.
Robolectric runtime dependencies downloader
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
/** | |
* Module that includes this will be configured to use offline dependencies for Robolectric | |
* This downloads robolectric dependencies once into the root project | |
*/ | |
def robolectricDependenciesFolder = rootProject.buildDir.path + "/robolectric-dependencies" | |
// configuration that resolves Robolectric runtime dependencies | |
configurations.create('robolectricRuntime') | |
// explicitly name required runtime dependencies | |
dependencies { | |
// runtime dependencies for org.robolectric:robolectric:3.0 | |
robolectricRuntime "org.ccil.cowan.tagsoup:tagsoup:1.2" | |
robolectricRuntime "org.robolectric:android-all:4.1.2_r1-robolectric-0" | |
robolectricRuntime "org.robolectric:shadows-core:3.0:16" | |
robolectricRuntime "org.json:json:20080701" | |
} | |
rootProject.task(type: Copy, overwrite: true, "downloadRobolectricDependencies") { | |
println "downloadRobolectricDependencies " + robolectricDependenciesFolder | |
from configurations.robolectricRuntime | |
into robolectricDependenciesFolder | |
} | |
tasks.all { | |
if (it.name.startsWith("test")) { | |
it.dependsOn(rootProject.tasks.findByName("downloadRobolectricDependencies")) | |
} | |
} | |
// tests have own system properties, cannot be set from gradle via -D | |
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
Thanks for this!