Skip to content

Instantly share code, notes, and snippets.

@Sloy
Last active October 25, 2022 10:56
Show Gist options
  • Save Sloy/84d82a1559a0da7308135554afa494c6 to your computer and use it in GitHub Desktop.
Save Sloy/84d82a1559a0da7308135554afa494c6 to your computer and use it in GitHub Desktop.
Replacing libraries with local projects in Gradle. More https://publicobject.com/2021/03/11/includebuild/
val CaptainCrunch = Lib("../android-common--lib-android-captain-crunch", "com.adevinta.android:captaincrunch" to ":captaincrunch")
val AndroidExtensions = Lib("../android-common--lib-android-extensions", "com.adevinta.android:android-extensions" to ":android-extensions")
val Barista = Lib("../Barista", "com.schibsted.spain:barista" to ":library")
val AbTestingRunner = Lib(
"../android-common--lib-abtesting-runner",
"com.adevinta.android:abtesting" to ":abtesting",
"com.adevinta.android:abtesting-apptimize" to ":abtesting-apptimize",
"com.adevinta.android:abtesting-optimizely" to ":abtesting-optimizely",
"com.adevinta.android:abtesting-debug" to ":abtesting-debug",
"com.adevinta.android:abtesting-debugdrawer" to ":abtesting-debugdrawer",
"com.adevinta.android:abtesting-debug-ui" to ":abtesting-debug-ui"
)
val DebugDrawer = Lib(
"../android-common--lib-debug-drawer",
"com.adevinta.android:debugdrawer" to ":debugdrawer",
"com.adevinta.android:debugdrawer-taggingviewer" to ":debugdrawer-taggingviewer",
"com.adevinta.android:debugdrawer-actions" to ":debugdrawer-actions",
"com.adevinta.android:debugdrawer-shortcuts" to ":debugdrawer-shortcuts",
"com.adevinta.android:debugdrawer-network-quality" to ":debugdrawer-network-quality",
"com.adevinta.android:debugdrawer-info" to ":debugdrawer-info"
)
val AdevintaAnalytics = Lib(
"../android-common--lib-analytics",
"com.adevinta.android:analytics" to ":analytics",
"com.adevinta.android:analytics-adobe" to ":analytics-adobe",
"com.adevinta.android:analytics-appsflyer" to ":analytics-appsflyer",
"com.adevinta.android:analytics-braze" to ":analytics-braze",
"com.adevinta.android:analytics-comscore" to ":analytics-comscore",
"com.adevinta.android:analytics-firebase" to ":analytics-firebase",
"com.adevinta.android:analytics-optimizely" to ":analytics-optimizely",
"com.adevinta.android:analytics-taggingviewer" to ":analytics-taggingviewer",
)
val localLibs = listOf<Lib>(
// CaptainCrunch,
// AndroidExtensions,
// Barista,
// AbTestingRunner,
// DebugDrawer,
// AdevintaAnalytics,
)
localLibs.forEach {
includeBuild(it.path) {
dependencySubstitution {
it.dependencies.forEach { (module, project) ->
substitute(module(module)).with(project(project))
}
}
}
}
class Lib(val path: String, vararg val dependencies: Pair<String, String>)
// Usual content
// ...
val localSettings = file("local.settings.gradle.kts")
if (localSettings.exists()) {
apply(from = localSettings)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment