forked from JcMinarro/Philology
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrobolectric.gradle
48 lines (42 loc) · 1.28 KB
/
robolectric.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import com.jcminarro.AndroidSdk
def allSdkConfigurations = []
task prefetchSdks() {
AndroidSdk.ALL_SDKS.each { androidSdk ->
def config = configurations.create("sdk${androidSdk.apiLevel}")
dependencies.add("sdk${androidSdk.apiLevel}", androidSdk.coordinates)
// causes dependencies to be resolved:
config.files
allSdkConfigurations << config.files.first()
}
}
task prefetchDependencies() {
dependsOn "prefetchSdks"
doLast {
allprojects.each { p ->
['compile', 'runtime', 'testCompile', 'testRuntime'].each { configName ->
if (p.configurations.findByName(configName)) {
// causes dependencies to be resolved:
p.configurations[configName].files
}
}
}
}
}
task copyRobolectricSdk() {
dependsOn prefetchDependencies
doLast {
def robolectricSdkFolder = new File("$buildDir/robolectricSdk")
robolectricSdkFolder.mkdirs()
allSdkConfigurations.forEach { filePath ->
copy {
from filePath
into "$buildDir/robolectricSdk"
}
}
}
}
subprojects.forEach{
it.getTasksByName("test", true).forEach{
it.dependsOn copyRobolectricSdk
}
}