https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

Sebastian Lehrbaum

11/01/2023, 6:51 PM
I have updated my Multiplatform project to Kotlin 1.9.20 and I get this error:
w: The Default Kotlin Hierarchy Template was not applied to 'project ':frontendshared'':
because I added some custom source sets. So I added
applyDefaultHierarchyTemplate()
and now I get
Unresolved reference: applyDefaultHierarchyTemplate
even though Intellij thinks it should exist. Here is the full project. A simple Gradle sync in Intellij/Android Studio or a clean will give the error. (The Kotlin Version is in Version.kt in BuildSrc, there is no other version defined) I also tried a more extensive approach, with upgrading Gradle and using the new easy accessors for the source sets and changing the desktop source set to jvm, but that didn't help either. Since it increases the amount of error messages, I pushed it to a separate branch. Thank you for your help! EDIT: Issue found The issue is a Plugin
com.codingfeline.buildkonfig
, when removed the build works fine. I don't know why, but I assume the plugin does something strange.
j

Jeff Lockhart

11/01/2023, 7:05 PM
When using the default hierarchy template, you should remove the manual creation (
by creating
) and
dependsOn
declarations that the default hierarchy does for you.
It looks like your source set names also don't align with the default hierarchy template. You have a shared JVM + Android source set that is using the
jvmMain
source set name, but the default template uses this source set name for the JVM source set, which you are naming
desktopMain
. You should avoid reusing default source set names and instead name the additional source sets something else unique.
Docs on the default hierarchy template are here.
s

Sebastian Lehrbaum

11/01/2023, 8:15 PM
@Jeff Lockhart I have applied your suggested changes. I have replaced the desktop sourceset with the standard jvm name and renamed my jvmMain to jvmTargetsMain. The "Desktop" variant was working before, because i called the target
jvm("desktop")
, I can get behind the idea to make it standard for error resolution. I don't think I was creating any of the default declarations, they are all
by getting
statements. I'm only creating the custom source sets. If I missed something please clarify. To make it more clear, I replaced them with the new accessors that should come with 1.9.20. Intellij can resolve the accessors, but the gradle build cannot, this has increased the amount of errors significantly sadly. I have pushed this to a separate branch. The original "minimal" branch was intended to keep the changes from the working state minimal: https://github.com/findusl/initiative-tracker/tree/upgrade_kotlin_1_9_20
I found the issue, it is a completely separate plugin
com.codingfeline.buildkonfig
that causes the error
j

Jeff Lockhart

11/01/2023, 9:26 PM
That makes sense. Plugins like this will likely need to be updated to support the default hierarchy template correctly. I ran into this issue with KSP, that might be similar. I was referring to places like this, but I see you've removed those on this other branch.
10 Views