Closed
Description
This is improvement for incubated version catalog feature of Gradle 7M1
Expected Behavior
Allow to define dependency version, so it can be easily shared between
- versions catalogs eg. one catalog for prod and another one for test dependences (practical example: kotlin coroutines have different dependencies for prod and testing with the same lib version)
- versions catalogs and gradle plugin versions (practical example:
kotlin-reflect
andJetPack Navigation
both require gradle plugin and dependency with the same version):
// Case 1 - Kotlin (want to share version between dependency and Gradle plugin)
//Gradle plugin
org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30
//Lib dependency
org.jetbrains.kotlin:kotlin-stdlib:1.4.30 // I know now this cna be optional
org.jetbrains.kotlin:kotlin-reflect:1.4.30 // Can't be optional
// Case 2 - Navigation (want to share version between dependency and Gradle plugin)
//Gradle plugin
androidx.navigation:navigation-safe-args-gradle-plugin:2.3.3
//Lib dependency
"androidx.navigation:navigation-fragment-ktx:2.3.3"
"androidx.navigation:navigation-dynamic-features-fragment:2.3.3"
"androidx.navigation:navigation-ui-ktx:2.3.3"
// Case 3 - Coroutines (need to share version between implementation and test implementation)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.9")
Current Behavior
Dependency version defined in version catalog can only be shared in context of version catalog
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
version("kotlin", "1.4.30")
alias("kotlin").to("org.jetbrains.kotlin", "kotlin-stdlib").versionRef("kotlin")
}
}
}
Context
Goals here are:
- Have a single place in te project (file or folder) to define all of the dependencies for the project this includes all library dependencies and Gradle plugins
- Define dependency version for given tool only once, especially in the case where Gradle plugin and library are sharing version - this way we don’t have to remember about updating the same dependency in multiple places (edited)
More:
https://gradle-community.slack.com/archives/CAD95CR62/p1612804019033000