gradle-buildconfig-plugin: Build failure for multiplatform projects

Heads up - this problem popped up in one of my projects with the latest release - it was fine in v5.5.4. Minimal reproducer:

plugins {
  kotlin("multiplatform") // v2.1.20
  id("com.android.library") // v8.9.0
  id("com.github.gmazzo.buildconfig") // v5.6.0
}

android {
  namespace = "com.whatever.whocares"
  compileSdk = 35

  defaultConfig {
    minSdk = 24
  }
}

buildConfig {
  packageName("com.whatever.whocares")
  className("MyBuildConfig")
  useKotlinOutput()
  buildConfigField(name = "SOME_FIELD", value = true)
}

kotlin {
  jvm()
  androidTarget()
}

If I remove useKotlinOutput, it runs perfectly fine.

Failure message when running gradle my-module:assemble:

e: File '/home/jon/dev/my-project/my-module/build/generated/java/generateNonAndroidBuildConfig/com/whatever/whocares/MyBuildConfig.kt' can be a part of only one module, but is listed as a source for both `androidDebug` and `commonMain`, please check you -Xfragment-sources options.

Big fan of the plugin by the way! Super duper useful

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 19 (10 by maintainers)

Most upvoted comments

Thanks everyone for reporting this!

@valeriyo I don’t thin #227 would affect non-Andorid targets, but if it did, please open a new ticket. In #233 I’ve added a test case for it in the demo project just in case.

Here’s a public repro: https://github.com/ZacSweers/FieldSpottr/pull/147

@ZacSweers fixed in v5.6.1. By the way, since #221 this plugin is also in Maven Central, probably you would like to remove includeGroup("com.github.gmazzo.buildconfig") from the Plugins Portal filter.

Verified the fix in 5.6.5 – @gmazzo, you’re awesome! 🎉

@gmazzo Thanks for reaching out (again). Just gave you access to my private repo.

Changing the version of your plugin in libs.version.toml, eg buildconfig = "5.6.4"

and running the js target app via ./gradlew jsBrowserDevelopmentRun should yield the error.

Hope that helps.

@gmazzo Thanks for your fix, it works 🎉

Confirmed, reopneing the issue

After some back and forth, I finally manage to reproduce it in a little project. You can check here: https://github.com/vinceglb/BuildConfigBugRepro