jarad2's picture
Add Android Bench sample: tasks and runs (part 14)
89995d3 verified
Raw History Blame Contribute Delete
2.99 kB
// Image build only (Dockerfile): resolves the unit-test and instrumented-test classpaths of :app (foss debug), with a
// set of widely used test libraries added when WARM_TEST_LIBRARIES=1, so that their artifacts are in the Gradle cache.
// Versions follow what the app already resolves (coroutines 1.9.0, lifecycle 2.10.0, Kotlin 2.3.10, Compose UI 1.9.2)
// or are the libraries' current stable releases. Robolectric's own Android runtime downloads use the same mirror.
def unitLibraries = [
'junit:junit:4.13.2',
'org.jetbrains.kotlin:kotlin-test-junit:2.3.10',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0',
'org.robolectric:robolectric:4.16',
'androidx.compose.ui:ui-test-junit4:1.9.2',
'androidx.compose.ui:ui-test-manifest:1.9.2',
'androidx.test:core:1.6.1',
'androidx.test:core-ktx:1.6.1',
'androidx.test.ext:junit:1.2.1',
'androidx.test.ext:junit-ktx:1.2.1',
'androidx.arch.core:core-testing:2.2.0',
'androidx.lifecycle:lifecycle-runtime-testing:2.10.0',
'io.mockk:mockk:1.14.2',
'app.cash.turbine:turbine:1.2.0',
'com.google.truth:truth:1.4.4',
]
def instrumentedLibraries = [
'junit:junit:4.13.2',
'androidx.test:runner:1.6.2',
'androidx.test:rules:1.6.1',
'androidx.test:core-ktx:1.6.1',
'androidx.test.ext:junit-ktx:1.2.1',
'androidx.test.espresso:espresso-core:3.6.1',
'androidx.compose.ui:ui-test-junit4:1.9.2',
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0',
'io.mockk:mockk-android:1.14.2',
'app.cash.turbine:turbine:1.2.0',
'com.google.truth:truth:1.4.4',
]
allprojects { p ->
p.afterEvaluate {
if (p.path != ':app') return
p.tasks.withType(Test).configureEach { systemProperty 'robolectric.dependency.repo.url', 'https://maven.aliyun.com/repository/central' }
if (System.getenv('WARM_TEST_LIBRARIES') == '1') {
unitLibraries.each { p.dependencies.add('testImplementation', it) }
instrumentedLibraries.each { p.dependencies.add('androidTestImplementation', it) }
}
p.tasks.register('benchWarmTestClasspaths') {
doLast {
['fossDebugUnitTestCompileClasspath', 'fossDebugUnitTestRuntimeClasspath',
'fossDebugAndroidTestCompileClasspath', 'fossDebugAndroidTestRuntimeClasspath'].each { name ->
def c = p.configurations.findByName(name)
if (c == null) {
println "warm: ${name} missing"
return
}
def files = c.incoming.artifactView { lenient(true) }.files.files
def failed = c.incoming.resolutionResult.allDependencies.findAll {
it instanceof org.gradle.api.artifacts.result.UnresolvedDependencyResult
}
println "warm: ${name} ${files.size()} files, unresolved ${failed*.requested}"
}
}
}
}
}