yshrsmz / BuildKonfig

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

Support Kotlin 1.9.20 #108

Closed findusl closed 10 months ago

findusl commented 10 months ago

I have tried to upgrade my Multiplatform project to Kotlin 1.9.20 and it breaks unless I remove the plugin com.codingfeline.buildkonfig.

The error message has nothing to do with the plugin and makes understanding the problem very hard. Basically in Kotlin 1.9.20 when using custom source sets, one needs to explicitly call applyDefaultHierarchyTemplate(), however with the plugin included, you get the error Unresolved reference: applyDefaultHierarchyTemplate. I do not understand how this happens, something seems to go wrong between the multiplatform plugin and the buildkonfig plugin.

My example for verification: https://github.com/findusl/initiative-tracker/blob/upgrade_kotlin_1_9_20/frontendshared/build.gradle.kts

findusl commented 10 months ago

@yshrsmz I'd love to try and contribute. I'm having a hard time finding a place to start, because Kotlin Multiplatform fails and there is no warning message from your plugin. The only prove I have of an issue with the BuildKonfig plugin, is the fact that kotlin multiplatform works without the plugin. Do you have a suggestion where I could start looking? (I have not done Gradle plugins before but I know in principle how they work)

yshrsmz commented 10 months ago

I'm not sure for now. But #106 is passing so it can be fixed just by updating Kotlin dependency of BuildKonfig. I think I can look into it this weekend.

yshrsmz commented 10 months ago

OK, I've quickly tested 1.9.20 compatibility with the ./sample project

https://github.com/yshrsmz/BuildKonfig/compare/master...kotlin1.9.20-test

Executed the following commands

$ ./gradlew publishAllPublicationsToTestMavenRepository -PRELEASE_SIGNING_ENABLED=false
$ ./gradlew -p sample build

and sample project seems to compile fine with Kotlin 1.9.20 🤔

findusl commented 10 months ago

Very interesting. It appears the error only happens in a nested gradle structure using a build.gradle.kts. I have minimized your sample-kts so that it builds and shows the error: https://github.com/yshrsmz/BuildKonfig/compare/master...findusl:BuildKonfig:show-failure

findusl commented 10 months ago

Building the plugin with the new Kotlin 1.9.20 version and using this version fixes the problem. Looking back, you probably already had this effect with your publishAllPublicationsToTestMavenRepository command. That one did not work for me until I had removed the signing plugin.

Long story short, once #106 is merged, this can be closed.

Thank you for looking into it!

rs-georg commented 10 months ago

I encountered the same issue when I tried to upgrade a project to Kotlin 1.9.20 and was very happy to see that there's already a solution available. What is blocking this PR from being merged? Anything I could help with?

yshrsmz commented 10 months ago

Hi, just released v0.15.0

https://github.com/yshrsmz/BuildKonfig/releases/tag/v0.15.0

Please try it out and let me know if you find any issue(as a new issue)