facing a weird bug in KMP project with jvm and js target - compileKotlinJvm build successfully - com...
a
facing a weird bug in KMP project with jvm and js target • compileKotlinJvm build successfully • compileKotlinJs builds successfully • compileCommonMainKotlinMetadata fails with dependency resolution errors Anyone faced this issue before? What might the cause be? WA??
a
Hi! Can I see build log failure and gradle configuration? Its hard to say what went wrong.
a
If by build log failure you mean the gradle output, here it is
Task :authenticator-core:compileCommonMainKotlinMetadata
Copy code
. . .
> Task :authenticator-core:compileCommonMainKotlinMetadata FAILED
e: /media/andylamax/Auxilliary/Workspace/PiCortex/authenticator/core/src/commonMain/kotlin/authenticator/UsersServiceCore.kt: (3, 8): Unresolved reference: bitframe
e: /media/andylamax/Auxilliary/Workspace/PiCortex/authenticator/core/src/commonMain/kotlin/authenticator/UsersServiceCore.kt: (4, 8): Unresolved reference: bitframe
e: /media/andylamax/Auxilliary/Workspace/PiCortex/authenticator/core/src/commonMain/kotlin/authenticator/UsersServiceCore.kt: (5, 8): Unresolved reference: bitframe
e: /media/andylamax/Auxilliary/Workspace/PiCortex/authenticator/core/src/commonMain/kotlin/authenticator/UsersServiceCore.kt: (6, 8): Unresolved reference: later
e: /media/andylamax/Auxilliary/Workspace/PiCortex/authenticator/core/src/commonMain/kotlin/authenticator/UsersServiceCore.kt: (9, 22): Unresolved reference: RequestBody
e: /media/andylamax/Auxilliary/Workspace/PiCortex/authenticator/core/src/commonMain/kotlin/authenticator/UsersServiceCore.kt: (9, 47): Unresolved reference: RegisterUserParams
e: /media/andylamax/Auxilliary/Workspace/PiCortex/authenticator/core/src/commonMain/kotlin/authenticator/UsersServiceCore.kt: (9, 69): Unresolved reference: Later
e: /media/andylamax/Auxilliary/Workspace/PiCortex/authenticator/core/src/commonMain/kotlin/authenticator/UsersServiceCore.kt: (9, 75): Unresolved reference: SignInResult

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':authenticator-core:compileCommonMainKotlinMetadata'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at <https://help.gradle.org>

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See <https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD FAILED in 18s
242 actionable tasks: 9 executed, 233 up-to-date
a
You said it fails with dependency resolution errors. Here I see that
commonMain
cant see some declarations. Are you sure that they must be accessible? The reason why
compileKotlinJvm
and
compileKotlinJs
work is because they see such dependencies from their platform variants. It is still unclear why it fails.
a
I just found out that even
compileKotlinMetadata
builds fine as well
if this helps, IDEA also marks the declarations as unresolvable
a
Ok I got it. Do you use
kotlin.mpp.enableCompatibilityMetadataVariant=true
?
a
No, I don't. Should I add it?
a
No, I was curious why then
compileKotlinMetadata
builds fine but
compileCommonMainKotlinMetadata
don't. With such property, it can occur. So back to your situation. Can you make a sample project that reproduces your issue? Because It is hard to say what is wrong based on the information you gave.
a
Will try to do so. But just to add a bit of context, I am using gradle's composite builds, these dependencies are swapped in place with "includeBuild", is that a know issue?
a
Well, I can't understand what is the issue on Kotlin's side at the moment. The only thing I see now is that code in
commonMain
can't be compiled. So I need more context 🤷
a
Let me try to work on a reproducer then
m
I got errors like this when the
maven-publish
plugin is applied.
a
what the hell. Removing
maven-publish
actually works. Thanks alot @mkrussel
what do I do when I still need to be able to publish?? Any known WA?
m
What I did was create a flag that could be passed in when I want to publish. I then only applied the plugin when that flag was present. Then when it came to configuring the iOS source sets. If i was publishing I did not use the
ios
function but instead called each iOS target manually. I also then added the folders
iosMain
and
iosTest
to the created target based source sets. I don't do that when not publishing because it confuses Android Studio with directories belonging to multiple source sets. The warning is "Duplicate Source Sets Detected".
a
What kotlin version do you use? 1.6.20?
m
I'm on 1.6.10
a
And what happens if you upgrade to 1.6.20?
a
also, I never stumbled upon this problem until I started using composite builds. Are you using composite builds by any chance??
a
I am on 1.6.21 @Anton Lakotka [JB] But I still face the problem
bumping to 1.7.0-RC2 didn't help either
m
I attached an simple repo case to the ticket
a
Right, so composite builds technically can cause such issues. But I have some context now. And thanks for the YouTrack issue. I'll take a look