Build: Make robolectric tests run offline without downloading artifacts
#KTI-1367
This commit is contained in:
committed by
Space Team
parent
bb8d3a0f80
commit
009cda0c60
@@ -7,6 +7,8 @@ plugins {
|
||||
}
|
||||
|
||||
val robolectricClasspath by configurations.creating
|
||||
val robolectricDependency by configurations.creating
|
||||
|
||||
val androidExtensionsRuntimeForTests by configurations.creating
|
||||
val layoutLib by configurations.creating
|
||||
val layoutLibApi by configurations.creating
|
||||
@@ -37,8 +39,9 @@ dependencies {
|
||||
testApi(project(":kotlin-test:kotlin-test-jvm"))
|
||||
testApi(commonDependency("junit:junit"))
|
||||
|
||||
robolectricDependency("org.robolectric:android-all:5.0.2_r3-robolectric-r0")
|
||||
|
||||
robolectricClasspath(commonDependency("org.robolectric", "robolectric"))
|
||||
robolectricClasspath("org.robolectric:android-all:4.4_r1-robolectric-1")
|
||||
robolectricClasspath(project(":kotlin-android-extensions-runtime")) { isTransitive = false }
|
||||
|
||||
embedded(project(":kotlin-android-extensions-runtime")) { isTransitive = false }
|
||||
@@ -65,10 +68,19 @@ javadocJar()
|
||||
|
||||
testsJar()
|
||||
|
||||
val robolectricDependencyDir = "$buildDir/robolectricDependencies"
|
||||
val prepareRobolectricDependencies by tasks.registering(Copy::class) {
|
||||
from(robolectricDependency)
|
||||
into(robolectricDependencyDir)
|
||||
}
|
||||
|
||||
projectTest {
|
||||
dependsOn(androidExtensionsRuntimeForTests)
|
||||
dependsOn(robolectricClasspath)
|
||||
|
||||
dependsOn(prepareRobolectricDependencies)
|
||||
dependsOn(":dist")
|
||||
|
||||
workingDir = rootDir
|
||||
useAndroidJar()
|
||||
|
||||
@@ -86,6 +98,10 @@ projectTest {
|
||||
doFirst {
|
||||
systemProperty("androidExtensionsRuntime.classpath", androidExtensionsRuntimeProvider.get())
|
||||
systemProperty("robolectric.classpath", robolectricClasspathProvider.get())
|
||||
|
||||
systemProperty("robolectric.offline", "true")
|
||||
systemProperty("robolectric.dependency.dir", robolectricDependencyDir)
|
||||
|
||||
systemProperty("layoutLib.path", layoutLibConf.singleFile.canonicalPath)
|
||||
systemProperty("layoutLibApi.path", layoutLibApiConf.singleFile.canonicalPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user