nowinandroid
nowinandroid copied to clipboard
Hotfix broken build with a test
What I have done and why
Fix #1544
@machado001 Thanks for your comment.
From this documentation. https://kotlinlang.org/docs/gradle-configure-project.html#set-dependencies-on-test-libraries
You can use shorthand for a dependency on a Kotlin module, for example, kotlin("test") for "org.jetbrains.kotlin:kotlin-test".
We use Kotlin DSL and it gives us kotlin shorthand kotlin("test")
kotlin("test") is more shorten and clear than version catalog, and it reduces that what we have to manage a dependency as we delegate it to kotlin.
I found same thing on Groovy also can use shorthand.
kotlin {
sourceSets {
commonTest {
dependencies {
implementation kotlin("test") // This brings all the platform dependencies automatically
}
}
}
}
Hi @Jaehwa-Noh, thank you for your reply.
I agree that using kotlin("test") is clean enough. Just to provide another perspective, I suggested adding the library to the version catalog to maintain project consistency and have a centralized place to manage and document dependencies.
New developers can start contributing to the project by looking at the version catalog file to get a general overview of the libraries and plugins used in the project.
I checked another build.gradle.kts file, particularly from the :lint module, and it looks like kotlin("test") is already used there. This could become a recurrent dependency that isn't declared in the version catalog, requiring developers to check each module individually to discover this.
Thus, another advantage is that, from the version catalog, developers can simply Ctrl + click (or Ctrl + B) to check which modules use the dependency.
@machado001 Yes, you have the reason. Simple way is you can found all usage in search all files Ctrl + Shift + F (Find all files). On this topic, I can't determine which way is better on my own. Let us hear the other developers' and maintainers' opinions.
I would prefer the explicit declaration of kotlin-test dependency in libs.versionss.toml.
Following #1560, not only fixed #1544 but also replaced kotlin("test") to version catalog kotlin.test for consistent.
Superseded #1667