This message was deleted.
# kotlin-dsl
s
This message was deleted.
c
This should do it:
Copy code
rootProject.the<VersionCatalogsExtension>().find("libs)
s
Thanks, yeah as i mentioned, from the main source. I understand how to access that data from build script. I want something like buildconfig generated (at compile time) with dependency name and versions.
c
What is “main source”?
Keep in mind that the version catalog are only suggestions - not everything there is used in dependencies, and those that are are “suggestions” for versions subject to dependency resolution. Sounds what you may want is the list of resolved dependencies?
s
version catalog are only suggestions
yeah i understand that.
“main source”
Your application source. Say i have a spring boot app, which have an api to list all the dependencies and it’s version defined in the catalog. I understand it’s not the resolved config. But it would be great to read some other info which i kept in version catalogs like
Copy code
[versions]
java                           = "20"
kotlin                         = "1.7.20-Beta"
kotlin-jvm-target              = "18"
kotlin-api-version             = "1.8"
kotlin-lang-version            = "1.8"
gradle                         = "7.7-20220817221725+0000"
c
sure. a few options. include the toml file in your jar task, and write the code to pull it in a runtime. Or you could generate effectively the same thing from the VersionCatalogExtension. Though the utility of this is questionable - all those versions are subject to dependency resolution or other changes, and would be misleading to include. For accuracy, grab the Java version from the toolchain in use, grab the Gradle version from Gradle itself, Kotlin info from compile task, etc.
s
nclude the toml file in your jar task, and write the code to pull it in a runtime.
yeah, that’s one option. But i am looking for a. type safe one.
For accuracy, grab the Java version from the toolchain in use, grab the Gradle version from Gradle itself, Kotlin info from compile task, etc.|
Got it.. the thing is, in my case, those values are set from the version catalog.
Copy code
java {
  withSourcesJar()
  withJavadocJar()

  toolchain {
 languageVersion.set(JavaLanguageVersion.of(libs.versions.java.asProvider().get()))
  }
  // modularity.inferModulePath.set(true)
}
c
None of this will be typesafe as you are crossing application boundaries, from Gradle to the runtime environment of your application. You’ll need to write the type safety into your application to read the data into an appropriate type-safe structure if that’s the goal.