Hi! I noticed that the naming conventions for libr...
# gradle
z
Hi! I noticed that the naming conventions for libraries and plugins in
libs.versions.toml
are different (libraries use lowercase with
-
, plugins use lower camel case). Is there a standard in this regard? Should I follow this naming convention?
v
You talk about "the naming conventions", but which naming conventions are your talking about? Generally it depends on how you want the syntax on usage to be. On https://blog.gradle.org/best-practices-naming-version-catalog-entries there are some naming convention suggestions by Gradle
z
This article seems to conflict with Kotlin's naming convention. For example, in the first picture of this article, it has
android-application
in plugins. But kmp.jetbrains.com uses
androidApplication
.
v
That blog article is from July last year, maybe that KMP generator predates that. Or maybe they just don't agree to those naming conventions. 🤷‍♂️ After all they are just conventions and you can do how you like it. Most important imho is, that you are consistent within a project.
t
hm, still valid feedback and we should be consistent in KMP wizard
v
Consistent with what? Within the generated build it somewhat can be considered consistent, within plugins and within libraries. 🙂 As they are different things there being consistent across both is not necessarily a requirement. 😄 Or did you mean consistent with the Gradle blog?
z
Some libraries now use
versionCatalogs
instead of BOM to manage versions, and the lack of clear naming conventions may indeed cause confusion/inconsistency. For example:
Copy code
// settings.gradle.kts
dependencyResolutionManagement {
    versionCatalogs {
        create("cryptographyLibs") {
            from("dev.whyoleg.cryptography:cryptography-version-catalog:0.4.0")
        }
        create("kotlincryptoLibs") {
            from("org.kotlincrypto:version-catalog:0.7.0")
        }
    }
}
v
Well, that you probably can never get managed as all projects providing a version catalog would need to agree to use the same conventions and like always with conventions, different projects can easily disagree on the conventions to be used. Besides that BOM/platform and version catalogs are accompanying concepts, not alternatives. So one cannot really replace the other, except one was misused for the use-case the other is better suited for.
t
In general we are going to do small build configuration improvements for generated by wizard KMP project. Will update version catalogs part as well.
j
I think there is no inconsistency there, it is just two ways to do the same. The first one wants to flatten the usage, and the second one goes for grouping under a name, for example
android
But I would expect having something like
foo-bar-bazQuxQuz