Vlad
06/27/2024, 10:54 PM.kt
file doesnât detect use - declarations within the .toml
file are not reported as used.
Iâm trying to add use of version catalog with .toml
file into my existing project, which uses buildSrc. When libs
is accessed from any module build.gradle.kts
if I âclick-throughâ on it, it leads to the declaration in the .toml
file, which is marked as used. But if it is accessed in buildSrc âclick-throughâ leads to the LibrariesForLibs
class, while in the .toml
file it stays marked as unused.
⢠I added the libs.versions.toml
file with dependencies to gradle
folder
⢠I added the /builsSrc/settings.gradle.kts
with
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
⢠In /builsSrc/build.gradle.kts
dependencies I added
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
This enables the use of LibrariesForLibs
within the buildSrc with:
val libs = the<LibrariesForLibs>()
(see the screenshots)
Can it be made so that it marks it as used in the .toml
file when used from extension in .kt
in buildSrc?Vlad
06/27/2024, 10:57 PMVampire
06/27/2024, 10:59 PMVampire
06/27/2024, 10:59 PMVlad
06/27/2024, 11:03 PMVampire
06/27/2024, 11:09 PMbuildSrc
classes.
The one you just replicated above in your unordered list.
You don't need to stop using it, but if you use it, you should not wonder if for example things like usage detection in the IDE does not work as expected.
The officially supported way to use the version catalog in cases where my hack-around is needed, is to use the VersionCatalogsExtension
and its string-y API, instead of type-safe accessors.Vlad
06/27/2024, 11:12 PMVampire
06/27/2024, 11:42 PMVampire
06/27/2024, 11:44 PM