ursus
07/10/2024, 7:57 PM@Serializable
annotation
interface UserApiClient {
suspend fun user(): ApiUser
}
@Serializable
data class ApiUser(
val userId: Long,
val username: String?,
..
)
is or is not @Serializable
part of public interface?
i.e. should I kotlinx.serialization
runtime library be api
or implementation
?Vampire
07/10/2024, 8:01 PMcompileOnly
.
But here this will probably not apply as there is more in kotlinx.serialization
.
Not sure though if what is generated by the plugin is part of the API, but it might be.
If in doubt - or generally - use the dependency-analysis-gradle-plugin
.
It of course has some blind spots and edge cases, but generally it gives pretty good advices where which library should go to.ursus
07/10/2024, 8:03 PMmbonnin
07/10/2024, 8:03 PM@Serializable
classes are public, their serializers are public as well. See https://github.com/Kotlin/kotlinx.serialization/issues/2108#issuecomment-1326695476ursus
07/10/2024, 8:03 PMmbonnin
07/10/2024, 8:04 PMVampire
07/10/2024, 8:05 PMbut my thinking was exactly yours.. its a compile time marker, not part of signatureThe annotation, yes. But the point is, that your classes contain generated code added by the kxs serializer Gradle plugin. And whether that code contains kxs classes in the public API is the question. The
dependency-analysis-gradle-plugin
unfortunately does a wrong decision for annotations that are runtime retention imhoVampire
07/10/2024, 8:06 PMursus
07/10/2024, 8:09 PM@Serialzable
is not part of signature, but codegen adds stuff to binary interface therefore api kotlinx.serialization.json
Vampire
07/10/2024, 8:10 PMursus
07/10/2024, 8:11 PMursus
07/10/2024, 8:11 PMapi core
implementation json
?mbonnin
07/10/2024, 8:12 PMVampire
07/10/2024, 8:12 PMursus
07/10/2024, 8:12 PMVampire
07/10/2024, 8:12 PMVampire
07/10/2024, 8:13 PMursus
07/10/2024, 8:13 PMJson
etc?Vampire
07/10/2024, 8:13 PMJsonName
and so onVampire
07/10/2024, 8:14 PMreason
task to at least see one or some of the reasons for the given advice.Vampire
07/10/2024, 8:14 PMVampire
07/10/2024, 8:15 PMcompileOnly
, but you probably use it in the implementation of your methods, so then implementation
ursus
07/10/2024, 8:16 PMcompileOnly
if the annots are core
?ursus
07/10/2024, 8:16 PMVampire
07/10/2024, 8:18 PMJsonName
.
If you for example do not do any serialization but only make a library that can be used with KxS properly, then you might just have some format-specific annotations but no other classes.Vampire
07/10/2024, 8:18 PMursus
07/10/2024, 8:20 PM