Skip to content

Commit

Permalink
Create dependency bundles for testing libs (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars885 authored Aug 21, 2024
1 parent aaa891b commit aedc344
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 73 deletions.
4 changes: 0 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ dependencies {

implementation(libs.commonsCore)
implementation(libs.commonsKtx)

testImplementation(libs.jUnit)

androidTestImplementation(libs.jUnitExt)
}

val installGitHook by tasks.registering(Copy::class) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.paulrybitskyi.gamedge.extensions

import org.gradle.api.artifacts.ExternalModuleDependencyBundle
import org.gradle.api.artifacts.dsl.DependencyHandler

fun DependencyHandler.addBundle(configurationName: String, bundle: ExternalModuleDependencyBundle) {
bundle.forEach { dependency ->
add(configurationName, dependency)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ class GamedgeAndroidPlugin : Plugin<Project> {
return (get(key) as T)
}

private fun Project.addDependencies() {
dependencies.add("coreLibraryDesugaring", libs.desugaredJdk.get())
dependencies.add("androidTestImplementation", project(localModules.commonTesting))
private fun Project.addDependencies(): Unit = with(dependencies) {
add("implementation", libs.coroutines.get())
add("implementation", libs.kotlinResult.get())

add("coreLibraryDesugaring", libs.desugaredJdk.get())
add("androidTestImplementation", project(localModules.commonTesting))
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.paulrybitskyi.gamedge.plugins

import com.paulrybitskyi.gamedge.extensions.addBundle
import com.paulrybitskyi.gamedge.extensions.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -24,19 +25,11 @@ class GamedgeFeaturePlugin : Plugin<Project> {
add("implementation", project(localModules.core))
add("implementation", project(localModules.commonUi))
add("implementation", project(localModules.commonUiWidgets))
add("implementation", libs.coroutines.get())
add("implementation", libs.composeHilt.get())
add("implementation", libs.commonsCore.get())
add("implementation", libs.commonsKtx.get())
add("implementation", libs.kotlinResult.get())
add("implementation", libs.coil.get())
add("testImplementation", project(localModules.commonTesting))
add("testImplementation", libs.jUnit.get())
add("testImplementation", libs.truth.get())
add("testImplementation", libs.mockk.get())
add("testImplementation", libs.coroutinesTesting.get())
add("testImplementation", libs.turbine.get())
add("androidTestImplementation", libs.testRunner.get())
add("androidTestImplementation", libs.jUnitExt.get())
addBundle("testImplementation", libs.bundles.testing.get())
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.paulrybitskyi.gamedge.plugins

import com.android.build.api.dsl.LibraryExtension
import com.paulrybitskyi.gamedge.extensions.addBundle
import com.paulrybitskyi.gamedge.extensions.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand Down Expand Up @@ -33,20 +34,13 @@ class GamedgeRemoteApiPlugin : Plugin<Project> {
add("api", project(localModules.commonApi))
add("implementation", project(localModules.core))

add("implementation", libs.coroutines.get())
add("implementation", libs.kotlinxSerialization.get())
add("implementation", libs.retrofit.get())
add("implementation", libs.kotlinResult.get())

add("testImplementation", project(localModules.commonTesting))
add("testImplementation", libs.jUnit.get())
add("testImplementation", libs.truth.get())
add("testImplementation", libs.mockk.get())
add("testImplementation", libs.coroutinesTesting.get())

add("androidTestImplementation", libs.testRunner.get())
add("androidTestImplementation", libs.jUnitExt.get())
add("androidTestImplementation", libs.truth.get())
addBundle("testImplementation", libs.bundles.testing.get())

addBundle("androidTestImplementation", libs.bundles.testingAndroid.get())
add("androidTestImplementation", libs.mockWebServer.get())
}
}
3 changes: 0 additions & 3 deletions common-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,4 @@ dependencies {
implementation(libs.retrofitKotlinxSerializationConverter)

implementation(libs.kotlinResult)

testImplementation(libs.jUnit)
androidTestImplementation(libs.jUnitExt)
}
13 changes: 1 addition & 12 deletions common-data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,9 @@ dependencies {
implementation(project(localModules.igdbApi))
implementation(project(localModules.database))

implementation(libs.coroutines)

implementation(libs.prefsDataStore)
implementation(libs.protoDataStore)

implementation(libs.kotlinResult)

testImplementation(project(localModules.commonTesting))
testImplementation(libs.jUnit)
testImplementation(libs.truth)
testImplementation(libs.mockk)
testImplementation(libs.coroutinesTesting)
testImplementation(libs.turbine)

androidTestImplementation(libs.testRunner)
androidTestImplementation(libs.jUnitExt)
testImplementation(libs.bundles.testing)
}
6 changes: 1 addition & 5 deletions common-domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,5 @@ dependencies {
kapt(libs.daggerHiltCoreCompiler)

testImplementation(project(localModules.commonTestingDomain))
testImplementation(libs.jUnit)
testImplementation(libs.truth)
testImplementation(libs.mockk)
testImplementation(libs.coroutinesTesting)
testImplementation(libs.turbine)
testImplementation(libs.bundles.testing)
}
3 changes: 0 additions & 3 deletions common-ui-widgets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,4 @@ dependencies {
implementation(project(localModules.commonUi))

implementation(libs.coil)

testImplementation(libs.jUnit)
androidTestImplementation(libs.jUnitExt)
}
3 changes: 0 additions & 3 deletions common-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,4 @@ dependencies {
implementation(libs.commonsKtx)

implementation(libs.coil)

testImplementation(libs.jUnit)
androidTestImplementation(libs.jUnitExt)
}
11 changes: 1 addition & 10 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ android {
dependencies {
implementation(project(localModules.commonDomain))

implementation(libs.coroutines)
implementation(libs.kotlinxSerialization)

implementation(libs.browser)
Expand All @@ -37,14 +36,6 @@ dependencies {
implementation(libs.commonsNetwork)
implementation(libs.commonsWindowAnims)

implementation(libs.kotlinResult)

testImplementation(project(localModules.commonTesting))
testImplementation(libs.jUnit)
testImplementation(libs.truth)
testImplementation(libs.mockk)
testImplementation(libs.coroutinesTesting)

androidTestImplementation(libs.testRunner)
androidTestImplementation(libs.jUnitExt)
testImplementation(libs.bundles.testing)
}
13 changes: 2 additions & 11 deletions database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,16 @@ ksp {
dependencies {
implementation(project(localModules.core))

implementation(libs.coroutines)
implementation(libs.kotlinxSerialization)

implementation(libs.room)
implementation(libs.roomKtx)
ksp(libs.roomCompiler)

testImplementation(project(localModules.commonTesting))
testImplementation(libs.jUnit)
testImplementation(libs.truth)
testImplementation(libs.mockk)
testImplementation(libs.coroutinesTesting)
testImplementation(libs.turbine)
testImplementation(libs.bundles.testing)

androidTestImplementation(libs.testRunner)
androidTestImplementation(libs.jUnitExt)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.bundles.testingAndroid)
androidTestImplementation(libs.archCore)
androidTestImplementation(libs.coroutinesTesting)
androidTestImplementation(libs.turbine)
androidTestImplementation(libs.roomTesting)
}
18 changes: 18 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,21 @@ archCore = { module = "androidx.arch.core:core-testing", version.ref = "archCore
daggerHiltTesting = { module = "com.google.dagger:hilt-android-testing", version.ref = "daggerHilt" }
roomTesting = { module = "androidx.room:room-testing", version.ref = "room" }
mockWebServer = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "mockWebServer" }

[bundles]
testing = [
"jUnit",
"truth",
"mockk",
"coroutinesTesting",
"turbine",
]

testingAndroid = [
"testRunner",
"jUnit",
"jUnitExt",
"truth",
"coroutinesTesting",
"turbine",
]

0 comments on commit aedc344

Please sign in to comment.