yshrsmz / BuildKonfig

BuildConfig for Kotlin Multiplatform Project
Apache License 2.0
740 stars 33 forks source link

Usage in build.gradle.kts #15

Closed clojj closed 4 years ago

clojj commented 4 years ago

Hi

How can I do the buildkonfig in the Gradle Kotlinscript variant ?

buildkonfig { } gives me a syntax error obviously

clojj commented 4 years ago
plugins {
    kotlin("multiplatform")
    id("kotlinx-serialization")
    id("com.codingfeline.buildkonfig")
}

configure<com.codingfeline.buildkonfig.gradle.BuildKonfigExtension> {
    packageName = "com.example.app"

    // default config is required
    defaultConfigs {
        buildConfigField( com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING, "name", "value")
    }
}

Problem solved !

clojj commented 4 years ago

actually much nicer because of IDE help in the Kotlin DSL

clojj commented 4 years ago

works with build.gradle.kts too

Murtowski commented 1 year ago

@yshrsmz for Kotlin DSL only syntax mentioned by @clojj works. If this is not fixed, could You please update README by alternative code snipped for KotlinDSL 🙏🏼 - it will save time of the people working with Kotlin Gradle

yshrsmz commented 1 year ago

As you can see in sample-kts directory, it should work.