Edoardo Luppi
08/09/2023, 11:38 AM@file:JvmName
work in commonMain
? Or, is it expected to work?
Currently the file name is not changed.mbonnin
08/09/2023, 11:40 AMmbonnin
08/09/2023, 11:40 AM.class
filesEdoardo Luppi
08/09/2023, 11:41 AM.class
files, I see it doesn't rename them as I would expect.
JvmName
doesn't work at allmbonnin
08/09/2023, 11:41 AMEdoardo Luppi
08/09/2023, 11:41 AMjvmMain
, it worksEdoardo Luppi
08/09/2023, 11:42 AMmbonnin
08/09/2023, 11:44 AMmbonnin
08/09/2023, 11:44 AM$ ls libraries/apollo-api/build/classes/kotlin/jvm/main/com/apollographql/apollo3/api/Adapters.class
libraries/apollo-api/build/classes/kotlin/jvm/main/com/apollographql/apollo3/api/Adapters.class
Edoardo Luppi
08/09/2023, 11:44 AMmbonnin
08/09/2023, 11:44 AMEdoardo Luppi
08/09/2023, 11:44 AMmbonnin
08/09/2023, 11:44 AMmbonnin
08/09/2023, 11:46 AMEdoardo Luppi
08/09/2023, 11:47 AMEdoardo Luppi
08/09/2023, 11:48 AMmbonnin
08/09/2023, 11:48 AM@file:JvmName
seems to be working there:
mbonnin:~/git/test-jvmname$ ./gradlew build
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to <https://docs.gradle.org/8.2/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.
BUILD SUCCESSFUL in 394ms
4 actionable tasks: 4 up-to-date
mbonnin:~/git/test-jvmname$ ls build/classes/kotlin/jvm/main/IAmRenamed.class
build/classes/kotlin/jvm/main/IAmRenamed.class
Edoardo Luppi
08/09/2023, 11:49 AMmbonnin
08/09/2023, 11:50 AMmbonnin
08/09/2023, 11:50 AMEdoardo Luppi
08/09/2023, 11:51 AMmbonnin
08/09/2023, 11:51 AM> Task :compileKotlinMacosArm64 FAILED
e: file:///Users/mbonnin/git/test-jvmname/src/commonMain/kotlin/Main.kt:1:7 Unresolved reference: JvmName
mbonnin
08/09/2023, 11:52 AMEdoardo Luppi
08/09/2023, 11:52 AMEdoardo Luppi
08/09/2023, 11:52 AMmbonnin
08/09/2023, 11:53 AMmbonnin
08/09/2023, 11:53 AM.class
file?Edoardo Luppi
08/09/2023, 11:54 AMEdoardo Luppi
08/09/2023, 11:58 AMexpect
and actualize it in jvmMain
, while keeping the JvmName
annotation in common, and you'll reproducembonnin
08/09/2023, 12:00 PM@file:JvmMultifileClass
?Edoardo Luppi
08/09/2023, 12:00 PMEdoardo Luppi
08/09/2023, 12:01 PMmbonnin
08/09/2023, 12:02 PMmbonnin
08/09/2023, 12:02 PM@file:JvmName
annotationsEdoardo Luppi
08/09/2023, 12:03 PMIf you have 2 files (one in commonMain, one in jvmMain)Yes you're right. The fact they have the same name is playing tricks in my brain
mbonnin
08/09/2023, 12:03 PMe: file:///Users/mbonnin/git/test-jvmname/src/commonMain/kotlin/Main.kt:1:1 Duplicate JVM class name 'IAmRenamed' generated from: IAmRenamed, IAmRenamed
e: file:///Users/mbonnin/git/test-jvmname/src/jvmMain/kotlin/Main.jvm.kt:1:1 Duplicate JVM class name 'IAmRenamed' generated from: IAmRenamed, IAmRenamed
This is where @file:JvmMultifileClass
comes inEdoardo Luppi
08/09/2023, 12:04 PMmbonnin
08/09/2023, 12:04 PM.jvm.kt
suffixes, etc.. for the target specific files, I tend to use that toombonnin
08/09/2023, 12:05 PMBut wait, I don't get any error thoMight be that one of those is empty? If there's no definition, I'm suspecting the Kotlin compiler doesn't emit a class at all
mbonnin
08/09/2023, 12:05 PMEdoardo Luppi
08/09/2023, 12:05 PMEdoardo Luppi
08/09/2023, 12:11 PMmbonnin
08/09/2023, 12:13 PM@JvmName
hereEdoardo Luppi
08/09/2023, 12:14 PMmbonnin
08/09/2023, 12:14 PMMain.kt
file in commonMain and the one in jvmMain are completely different filesEdoardo Luppi
08/09/2023, 12:15 PMmbonnin
08/09/2023, 12:15 PMactual
file name can be completely unrelated to the expected
definitionmbonnin
08/09/2023, 12:16 PM@JvmName
Edoardo Luppi
08/09/2023, 12:17 PMyou should use 2Which probably isn't my case as I want it renamed only at the JVM level. But good to know that multifileclass annotation exists. I need to scan that file for the other annotations too@JvmName
Edoardo Luppi
08/09/2023, 12:19 PMJvmPackageName
seemed interesting 👀, but it's internal.Edoardo Luppi
08/09/2023, 12:20 PMJvmPackageName
I thought I could have a single name as package, and then rename it for the JVM. That would have been coolmbonnin
08/09/2023, 12:22 PMWhich probably isn't my case as I want it renamed only at the JVM level.commonMain sources also create JVM classes
Edoardo Luppi
08/09/2023, 12:26 PMZCharsetKt
tho. I've removed the annotations in commonMain
, so I suppose that would be the name, right?mbonnin
08/09/2023, 12:49 PMEdoardo Luppi
08/09/2023, 12:54 PMEdoardo Luppi
08/09/2023, 12:55 PMmbonnin
08/09/2023, 12:56 PMmbonnin
08/09/2023, 12:58 PM