How to access plain Kotlin class in buildSrc from convention plugin?

I am writing a simple convention plugin to configure multiple Android library modules in an Android application project. The convention plugin is located in the root directory of the project in build-config.

I already use the buildSrc folder to maintain version numbers and strings in a plain Kotlin class.

Here is the simplified directory structure:

├── build-config
│   └── src/main/kotlin/AndroidLibraryConventionPlugin.kt
├── buildSrc
│   └── src/main/kotlin/Dependencies.kt

The configuration applied by the convention plugin also contains some version numbers and strings which I would like to maintain in single location to avoid duplication with what is defined in the buildSrc Kotlin class.

Is there a way to programmatically access the plain Kotlin class in buildSrc from the convention plugin?


Assuming build-config is an included build, no.
An included build is a completely standalone build and cannot access things from buildSrc of the “parent” build.
You would probably need to move those definitions to another included build, that you can then use where you used buildSrc and also in that build-config build.

But actually, to maintain version at a central location, I greatly recommend to use a version catalog instead, which is the idiomatic way and has various advantages over some source in buildSrc.