I've changed `:buildSrc` to included build, but I ...
# community-support
p
I've changed
:buildSrc
to included build, but I can't reference my constants in submodules now. What am I missing? Code in 🧵
structure:
Copy code
app/build.gradle.kts
build-logic/build.gradle.kts
build-logic/src/main/kotlin/Versions.kt
settings.gradle.kts
app/build.gradle.kts:
Copy code
plugins {
    alias(libs.plugins.kotlin.android)
    alias(libs.plugins.android.application)
}

android {
    val java = Versions.java <-- Unresolved reference
    compileOptions {
        targetCompatibility = java
        sourceCompatibility = java
    }
    // ...
}
Versions.kt
Copy code
object Versions {
    val java = JavaVersion.VERSION_17
}
settings.gradle.kts:
Copy code
rootProject.name = "My project"

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

include(":app")
includeBuild("build-logic")
v
As I said in the other thread.
buildSrc
classes and dependencies are always available in all buildscripts as they are added to a parent classloader which has its pros but mostly cons. Things from an included build are only built and added to the classpath if you actually use them. That is either declare a buildscript dependency on them or applying a plugin coming from them which is why your
Versions
class is not available currently. But using a
Versions
class like that is bad practice anyway due to various reasons. Better use the version catalog feature, especially with a TOML file.
🍺 1