gmazzo/gradle-buildconfig-plugin

Kotlin Multiplatform

ismai117 opened this issue · 1 comments

This works for Android and iOS but when I try to run the application for Desktop or Web I receive the following message

buildConfig {
    buildConfigField("String", "API_KEY", "\"${loadProperties("gradle.properties").getProperty("API_KEY")}\"")
}
1: Task failed with an exception.
-----------
* Where:
Build file '/Users/ismail/AndroidStudioProjects/KSend/lib/build.gradle.kts' line: 148

* What went wrong:
gradle.properties
gmazzo commented

Hi @ismai117, you'll need to elaborate a bit more about the issue. Maybe providing a stacktrace or better a sample project.

Said that, and based on the very limited info you have provided, I'm not willing to think this is not related to the plugin at all.

Your build script seems to be failing to run, probably because the gradle.properties you are reading.

Can you try to isolate that first? For instance, you don't need to manually read a gradle.properties file, as they are loaded by Gradle.

You could have:

val API_KEY: String by project

buildConfig {
    buildConfigField("String", "API_KEY", API_KEY)
}

Feel free to reopen the issue later.