cbeust / kobalt

A Kotlin-based build system for the JVM.
Apache License 2.0
432 stars 60 forks source link

BuildConfig not being generated. #464

Closed aerb closed 6 years ago

aerb commented 6 years ago

Following the instructions for generating build variants does not seem to be generating a BuildConfig file as documented.

kobalt-flavour.zip

cbeust commented 6 years ago

Well, the code was commented out...

Reactivating it fixes the problem but now I'm seeing a different issue that seems to be related to changes made in Kotlin's latest version of the compiler API:

com.beust.kobalt.KobaltException: Couldn't compile file: Source file or directory not found: /var/folders/qm/d9y7t5j523j_5g8cys5hzx5r0000gp/T/./src/main/kotlin/com/example/Main.kt
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:206)

I need to figure this one first but it might be tricky since the exception is thrown by the kotlinc API.

cbeust commented 6 years ago

Should be fixed in 1.0.92:

./kobaltw --update
./kobaltw assembleFreeRelease

Note that you need to call a variant target for that file to be generated (assembleFreeRelease, not just assemble).

Also, your build file was invoking field() with swapped parameters, it should be:

    productFlavor("free") {
        buildConfig {
            field("String", "aStringField", "\"The free field\"")
            field("Int", "anIntField", "42")
        }
    }