Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin generates invalid class so build fails #78

Closed
MichalKlusak opened this issue Dec 15, 2022 · 5 comments
Closed

Plugin generates invalid class so build fails #78

MichalKlusak opened this issue Dec 15, 2022 · 5 comments
Labels
bug Something isn't working contribution welcome help wanted Extra attention is needed

Comments

@MichalKlusak
Copy link

Hi. During first build, plugin generates expect object BuildKonfig (commonMain) and actual object BuildKonfig (androidMain+jvmMain) and everything works fine. But during second build (without any changes) it regenerates expect object in commonMain to actual object so build fails due to missing expect object and redeclaration of actual objects.
Below is part of my build.gradle file.

apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'com.android.library'
apply plugin: 'com.codingfeline.buildkonfig'

kotlin {
        android {
            compilations.all {
                kotlinOptions.jvmTarget = rootProject.ext.javaVersion
            }
        }
        jvm()

        sourceSets {
            all {
                languageSettings {
                    optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
                    optIn("kotlin.RequiresOptIn")
                }
            }

            commonMain {}
            jvmMain {}
            androidMain {}
            androidRc {}
            androidRelease {}
        }
}

buildkonfig {
        packageName = project.PACKAGE

        defaultConfigs {
              buildConfigField "BOOLEAN", "ABC", "true", const: true
        }

        targetConfigs {
            android {
                buildConfigField "BOOLEAN", "ABC", "true", const: true
            }

            jvm {
                buildConfigField "BOOLEAN", "ABC", "false", const: true
            }
        }
}
@yshrsmz
Copy link
Owner

yshrsmz commented Dec 16, 2022

@MichalKlusak Which Kotlin version are you using?
Also, simple repro is greatly appreciated

@yshrsmz yshrsmz added bug Something isn't working help wanted Extra attention is needed contribution welcome labels Mar 13, 2023
@LaurentPaquot
Copy link

LaurentPaquot commented Jun 14, 2023

I have the similar problem.
When I compile the first time my project the class is generated with internal object InjectedConfig which is fine (InjectedConfig is the name i have configured for the object)

image

I'm using kotlin 1.7.22, jdk 11, gradle 7.5.1 (I have enable the configuration-cache feature)
And when I'm running incremental builds, (sometimes) it re-generates the class with the 'actual' keyword. ("internal actual object InjectedConfig")
If I'm running my build with gradlew build --no-configuration-cache, it seems to regenerates the class properly.

Hope it will help you with the investigation for the potential bug fix.

@Popalay
Copy link

Popalay commented Jun 30, 2023

I've managed to fix this by removing org.gradle.unsafe.configuration-cache=true from the gradle.properties

@yshrsmz
Copy link
Owner

yshrsmz commented Aug 21, 2023

should be resolved with v0.14.0
https://github.com/yshrsmz/BuildKonfig/releases/tag/v0.14.0

@yshrsmz yshrsmz closed this as completed Aug 21, 2023
@yshrsmz
Copy link
Owner

yshrsmz commented Aug 21, 2023

If you want a patch release for v0.13.x, feel free to send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working contribution welcome help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants