ilyagulya
09/14/2023, 6:07 AM:kotlin-compiler-embeddable
build some packages are being relocated.
kotlinx.collections.immutable
is being relocated as well.
This leads to a string constants inside kotlin-parcelize
plugin being rewritten this way:
kotlinx.collections.immutable.PersistentList -> org.jetbrains.kotlin.kotlinx.collections.immutable.PersistentList
This rewrite breaks my kotlinx-parcelize
changes, since I need package names to match target project package names.
Is there a non-hacky way to exclude kotlinx-parcelize from package relocation process?dmitriy.novozhilov
09/14/2023, 6:26 AMembeddable
jars doesn't touch string constants, only FQNs of classes in .class
files
So you can't, for example, directly depend on kotlinx-serialization
in plugin and compare smth using FQNs from reflection (because on runtime of plugin classes will be renamed), but you perfectly can use some string constants
Check how it's done in Lombok plugin for exampleilyagulya
09/14/2023, 6:32 AM./gradlew publishToMavenLocal
and inspected the BuiltinParcelableTypes.class
Here’s rewritten constants 🙂
I can see the same ones during debug of kotlin compiler in the target project.
On the second screenshot you can see sources of this classilyagulya
09/14/2023, 6:32 AMilyagulya
09/14/2023, 6:34 AMkotlinx.collections.immutable
from packagesToRelocate
list inside embeddable.kt
and now constants look exactly as they should be.dmitriy.novozhilov
09/14/2023, 6:37 AMilyagulya
09/14/2023, 6:37 AMilyagulya
09/14/2023, 6:37 AMShadowJar
docs to find if I can exclude some owning packages from relocationdmitriy.novozhilov
09/14/2023, 6:40 AMval PARCELABLE_CONTAINER_FQNAMES = setOf(
...,
kotlinxImmutable("PersistentList")
)
private fun kotlinxImmutable(name: String): String {
return listOf("kotlinx", "collections", "immutable", name).joinToString(".")
}
dmitriy.novozhilov
09/14/2023, 6:40 AMkotlinx.collections.immutable
literal in the bytecodeilyagulya
09/14/2023, 6:41 AMdmitriy.novozhilov
09/14/2023, 6:42 AMilyagulya
09/14/2023, 6:42 AM