Skip to content

Commit

Permalink
fix(build): also inject test dependencies to androidTest source set
Browse files Browse the repository at this point in the history
  • Loading branch information
msfjarvis committed May 12, 2024
1 parent 7e31de6 commit 59acbe2
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/deps.ext.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2023 Harsh Shandilya.
* Copyright © 2023-2024 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
Expand All @@ -16,19 +16,23 @@ import org.gradle.kotlin.dsl.exclude
/** Extension function to configure JUnit5 dependencies with the Truth assertion library. */
fun DependencyHandlerScope.addTestDependencies(project: Project) {
val libs = project.extensions.getByName("libs") as LibrariesForLibs
addProvider("testImplementation", libs.junit.jupiter.api)
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
"testImplementation",
libs.truth,
) {
exclude(group = "junit", module = "junit")
}
addProvider("testRuntimeOnly", libs.junit.jupiter.engine)
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
"testRuntimeOnly",
libs.junit.legacy,
) {
// See https://github.com/google/truth/issues/333
because("Truth needs it")
}
arrayOf("test", "androidTest")
.filter { sourceSet -> project.configurations.findByName("${sourceSet}Implementation") != null }
.forEach { sourceSet ->
addProvider("${sourceSet}Implementation", libs.junit.jupiter.api)
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
"${sourceSet}Implementation",
libs.truth,
) {
exclude(group = "junit", module = "junit")
}
addProvider("${sourceSet}RuntimeOnly", libs.junit.jupiter.engine)
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
"${sourceSet}RuntimeOnly",
libs.junit.legacy,
) {
// See https://github.com/google/truth/issues/333
because("Truth needs it")
}
}
}

0 comments on commit 59acbe2

Please sign in to comment.