Skip to content

Commit

Permalink
Use same version of retrofit for minApi16 and minApi21
Browse files Browse the repository at this point in the history
  • Loading branch information
ARTI1208 committed Mar 26, 2023
1 parent f6ae753 commit f40efca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
12 changes: 8 additions & 4 deletions currency/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,21 @@ kotlin {
(this as ExternalModuleDependency).dependencyConfiguration()
}
}
fun implementation(
dependencyProvider: Provider<MinimalExternalModuleDependency>,
dependencyConfiguration: ExternalModuleDependency.() -> Unit
) = "implementation"(dependencyProvider.get(), dependencyConfiguration)

val okhttpGroup = libs.okhttp.okhttpMinApi16.get().group
"minApi16Implementation"(libs.okhttp.okhttpMinApi16)
"minApi16Implementation"(libs.retrofit.retrofitMinApi16.get()) {
implementation(libs.retrofit.retrofit) {
exclude(group = okhttpGroup)
}
"minApi16Implementation"(libs.retrofit.convertersimplexmlMinApi16.get()) {
implementation(libs.retrofit.convertersimplexml) {
exclude(group = okhttpGroup)
}

"minApi21Implementation"(libs.bundles.network.minApi21)
"minApi16Implementation"(libs.okhttp.okhttpMinApi16)
"minApi21Implementation"(libs.okhttp.okhttpMinApi21)
}
}
}
Expand Down
22 changes: 4 additions & 18 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ dependencyResolutionManagement {
okhttpMinApi16,
okhttpMinApi21,
)
val retrofitMinApi16 = version("retrofitMinApi16", "2.7.1")
val retrofitMinApi21 = version("retrofitMinApi21", "2.9.0")
val retrofitVersions = listOf(
retrofitMinApi16,
retrofitMinApi21,
)
val retrofit = version("retrofit", "2.9.0")
val leakcanary = version("leakcanary", "2.10")
val commonsMath = version("commonsMath", "3.6.1")
val slidingUpPanel = version("slidingUpPanel", "4.5.0")
Expand Down Expand Up @@ -125,8 +120,6 @@ dependencyResolutionManagement {
library("swiperefreshlayout", "androidx.swiperefreshlayout", "swiperefreshlayout")
.versionRef(swiperefreshlayout)

val networkAliases = mutableMapOf<String, MutableList<String>>()

fun <T> Iterable<T>.collectionSizeOrDefault(default: Int): Int = if (this is Collection<*>) this.size else default

fun <T, R, V> Iterable<T>.zipAll(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V> {
Expand All @@ -151,22 +144,15 @@ dependencyResolutionManagement {
).zipAll(okhttpVersions).forEach { (artifact, version) ->
val type = version.substringAfter("okhttp")
val alias = "okhttp-${artifact.replace("-", "")}$type"
networkAliases.computeIfAbsent(type) { mutableListOf() } += alias
library(alias, "com.squareup.okhttp3", artifact).versionRef(version)
}

listOf(
"retrofit",
"converter-simplexml",
).zipAll(retrofitVersions).forEach { (artifact, version) ->
val type = version.substringAfter("retrofit")
val alias = "retrofit-${artifact.replace("-", "")}$type"
networkAliases.computeIfAbsent(type) { mutableListOf() } += alias
library(alias, "com.squareup.retrofit2", artifact).versionRef(version)
}

networkAliases.forEach { (type, aliases) ->
bundle("network-$type", aliases)
).forEach { artifact ->
val alias = "retrofit-${artifact.replace("-", "")}"
library(alias, "com.squareup.retrofit2", artifact).versionRef(retrofit)
}

library("leakcanary", "com.squareup.leakcanary", "leakcanary-android")
Expand Down

0 comments on commit f40efca

Please sign in to comment.