mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 21:07:04 +05:30
refactor(build): simplify test dependency setup
This commit is contained in:
parent
c10ec27b51
commit
a5e25e2eb5
4 changed files with 45 additions and 24 deletions
|
@ -6,6 +6,8 @@
|
||||||
*/
|
*/
|
||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
|
import dev.msfjarvis.claw.gradle.addTestDependencies
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.msfjarvis.claw.android-application")
|
id("dev.msfjarvis.claw.android-application")
|
||||||
id("dev.msfjarvis.claw.rename-artifacts")
|
id("dev.msfjarvis.claw.rename-artifacts")
|
||||||
|
@ -74,14 +76,7 @@ dependencies {
|
||||||
|
|
||||||
kapt(libs.dagger.compiler)
|
kapt(libs.dagger.compiler)
|
||||||
|
|
||||||
testImplementation(libs.junit.jupiter.api)
|
|
||||||
testImplementation(libs.kotlinx.coroutines.test)
|
testImplementation(libs.kotlinx.coroutines.test)
|
||||||
testImplementation(libs.okhttp.mockwebserver)
|
testImplementation(libs.okhttp.mockwebserver)
|
||||||
testImplementation(libs.truth) { exclude(group = "junit", module = "junit") }
|
addTestDependencies(project)
|
||||||
|
|
||||||
testRuntimeOnly(libs.junit.jupiter.engine)
|
|
||||||
testRuntimeOnly(libs.junit.legacy) {
|
|
||||||
// See https://github.com/google/truth/issues/333
|
|
||||||
because("Truth needs it")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
* license that can be found in the LICENSE file or at
|
* license that can be found in the LICENSE file or at
|
||||||
* https://opensource.org/licenses/MIT.
|
* https://opensource.org/licenses/MIT.
|
||||||
*/
|
*/
|
||||||
|
import dev.msfjarvis.claw.gradle.addTestDependencies
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.msfjarvis.claw.android-library")
|
id("dev.msfjarvis.claw.android-library")
|
||||||
id("dev.msfjarvis.claw.kotlin-android")
|
id("dev.msfjarvis.claw.kotlin-android")
|
||||||
|
@ -24,15 +26,8 @@ dependencies {
|
||||||
implementation(libs.javax.inject)
|
implementation(libs.javax.inject)
|
||||||
|
|
||||||
testImplementation(testFixtures(libs.eithernet))
|
testImplementation(testFixtures(libs.eithernet))
|
||||||
testImplementation(libs.junit.jupiter.api)
|
|
||||||
testImplementation(libs.kotlinx.coroutines.test)
|
testImplementation(libs.kotlinx.coroutines.test)
|
||||||
testImplementation(libs.kotlinx.serialization.json)
|
testImplementation(libs.kotlinx.serialization.json)
|
||||||
testImplementation(libs.retrofit.kotlinxSerializationConverter)
|
testImplementation(libs.retrofit.kotlinxSerializationConverter)
|
||||||
testImplementation(libs.truth) { exclude(group = "junit", module = "junit") }
|
addTestDependencies(project)
|
||||||
|
|
||||||
testRuntimeOnly(libs.junit.jupiter.engine)
|
|
||||||
testRuntimeOnly(libs.junit.legacy) {
|
|
||||||
// See https://github.com/google/truth/issues/333
|
|
||||||
because("Truth needs it")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2023 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.
|
||||||
|
*/
|
||||||
|
package dev.msfjarvis.claw.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.artifacts.ExternalModuleDependency
|
||||||
|
import org.gradle.api.artifacts.MinimalExternalModuleDependency
|
||||||
|
import org.gradle.api.artifacts.VersionCatalogsExtension
|
||||||
|
import org.gradle.kotlin.dsl.DependencyHandlerScope
|
||||||
|
import org.gradle.kotlin.dsl.exclude
|
||||||
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
|
||||||
|
/** Extension function to configure JUnit5 dependencies with the Truth assertion library. */
|
||||||
|
fun DependencyHandlerScope.addTestDependencies(project: Project) {
|
||||||
|
val catalog = project.extensions.getByType<VersionCatalogsExtension>()
|
||||||
|
val libs = catalog.named("libs")
|
||||||
|
addProvider("testImplementation", libs.findLibrary("junit-jupiter-api").get())
|
||||||
|
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
|
||||||
|
"testImplementation",
|
||||||
|
libs.findLibrary("truth").get(),
|
||||||
|
) {
|
||||||
|
exclude(group = "junit", module = "junit")
|
||||||
|
}
|
||||||
|
addProvider("testRuntimeOnly", libs.findLibrary("junit-jupiter-engine").get())
|
||||||
|
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
|
||||||
|
"testRuntimeOnly",
|
||||||
|
libs.findLibrary("junit-legacy").get(),
|
||||||
|
) {
|
||||||
|
// See https://github.com/google/truth/issues/333
|
||||||
|
because("Truth needs it")
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,8 @@
|
||||||
* license that can be found in the LICENSE file or at
|
* license that can be found in the LICENSE file or at
|
||||||
* https://opensource.org/licenses/MIT.
|
* https://opensource.org/licenses/MIT.
|
||||||
*/
|
*/
|
||||||
|
import dev.msfjarvis.claw.gradle.addTestDependencies
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.msfjarvis.claw.android-library")
|
id("dev.msfjarvis.claw.android-library")
|
||||||
id("dev.msfjarvis.claw.kotlin-android")
|
id("dev.msfjarvis.claw.kotlin-android")
|
||||||
|
@ -33,14 +35,7 @@ dependencies {
|
||||||
implementation(libs.sqldelight.primitiveAdapters)
|
implementation(libs.sqldelight.primitiveAdapters)
|
||||||
implementation(projects.core)
|
implementation(projects.core)
|
||||||
|
|
||||||
testImplementation(libs.junit.jupiter.api)
|
|
||||||
testImplementation(libs.kotlinx.coroutines.core)
|
testImplementation(libs.kotlinx.coroutines.core)
|
||||||
testImplementation(libs.sqldelight.jvmDriver)
|
testImplementation(libs.sqldelight.jvmDriver)
|
||||||
testImplementation(libs.truth) { exclude(group = "junit", module = "junit") }
|
addTestDependencies(project)
|
||||||
|
|
||||||
testRuntimeOnly(libs.junit.jupiter.engine)
|
|
||||||
testRuntimeOnly(libs.junit.legacy) {
|
|
||||||
// See https://github.com/google/truth/issues/333
|
|
||||||
because("Truth needs it")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue