Hello ! I’ve got a small issue with gradle kts I’v...
# gradle
y
Hello ! I’ve got a small issue with gradle kts I’ve implemented plugin convention, so I have a
build-convention/convention
folder with all my
*ConventionPlugin
In one of my module I had a groovy task which was setting a buildConfigField and when I migrated it to kts it no longer creates that field When I uncomment the line in my
android
block it does create it I do have the
buildFeatures { buildConfig = true }
in my
custom.android.feature
Copy code
plugins {
    id("custom.android.feature")
}


tasks.create("myCustomTask") {
    // Process

    android.defaultConfig.buildConfigField("String", "CUSTOM_GRADLE_TASK_KEY", "\"TEST\"")
}


android {
    namespace = "com.example.app.features.home"
//    android.defaultConfig.buildConfigField("String", "CUSTOM_GRADLE_TASK_KEY_2", "\"TEST!!!\"")
}

dependencies {
    ...
}
v
Can you knit an MCVE?
y
I have fixed it, the task was never called
v
If that task is changing the configuration, that is anyway a big no-go, especially if you ever hope to use configuration cache.
y
I have added
Copy code
tasks.build {
    dependsOn("myCustomTask")
}
the only thing the task does is reading a file and adding a buildConfigField to the BuildConfig.java of this specific module. Does that count as changing the configuration?
Here is my MCVE
Copy code
class AndroidLibraryConventionPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        with(target) {
            with(pluginManager) {
                apply(libs.findPlugin("android.library").get().get().pluginId)
                apply(libs.findPlugin("kotlin.android").get().get().pluginId)
            }
        }
    }
}
// build.gradle.kts of my core module
Copy code
plugins {
    id("io.yoobi.library")
}

android {
    namespace = "io.yoobi.gradleconvention.core"
}
I’d like to create a BuildConfigField for this module, this BuildConfigField is generated by reading multiple file
v
I have no real idea about Android builds. But
buildConfigField
is something you usually configure in the build script, isn't it? So yes, if you change it at execution time, that is changing configuration
👍 1