-
Notifications
You must be signed in to change notification settings - Fork 623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider enabling serialization plugin by default in Kotlin distribution #2797
Comments
Interesting idea, but a precedent setting one. It almost screams for having something in the metadata of packages to allow automatic (compiler) plugin application. At the same time your rationale is valid (it is more a question whether it is worth the costs) |
I think consistency among plugins makes sense. Atomicfu has a similar question opened Kotlin/kotlinx-atomicfu#410 |
This one we rather generally prohibit. Having an implicitly-enabled compiler plugin from arbitrary dependencies (esp. taking into account that there are no compiler plugin APIs at all) is unlikely to be obvious, stable or healthy for an arbitrary user project. An attack vector as well, probably. Serialization here is in privileged position, as it is de facto the Kotlin serialization that we control, and, had we picked a slightly different turn, would've been part of the Kotlin default distribution.
My proposal only makes sense if the costs (for end users in terms of their build performance and stability; our maintenance cost is kind of out of question here) are negligible |
Implicitly enabling plugin by checking for I prefer the configuration of compose, by setting to true to enable a plugin: serialization {
enable = true
} And then we can enable the officially supported format in the same scope: serialization {
enable = true
json = true
protobuf = true
// Or this way
useFormat(Json, Protobuf)
} |
I'd like to point out that code generation is performed only for |
From that perspective I guess the checking for the library is more an optimization rather than anything else (btw. does the plugin just check that certain types exist on the class path?). Btw. when I mention cost it is more the "human" costs of confusion and/or setting precedents, not per se the processing/overhead cost. |
The idea behind the auto-enabled plugin is that it is enabled by default, and knows nothing about whether the project has any specific dependencies. What we can do to further push on Compose-like configuration is KGP DSL:
but it comes with a little bit different tradeoffs and should be considered in a bigger scope with the rest of core libraries |
I like the idea of automatic applying the serialization plugin because you always need to use the same KGP version (that needs to be applied too), and different plugin and runtime versions are confusing, especially for beginners. |
Currently,
kotlinx.serialization
requires two components to function -- applied serialization plugin and the runtime JAR added to dependencies.For newcomers, steepness of the general learning curve and build configuration, two-step procedure seems excessive (moreover, the overall plugin is rather an "implementation detail"), and we much likely can avoid that.
The serialization plugin is already bundled into Kotlin distribution, is released along with Kotlin and is, basically, part of the Kotlin.
I propose enabling it by default for all Kotlin project:
kotlinx-serialization-core
in dependencies, the plugin will do nothing and won't contribute to the overall build correctness and performance@Serializable
annotation by FQN (and other annotations fromkotlinx.*
package) and transform classes accordinglyEffectively, it won't change the overall build pipelines, but will allow us to get rid of an extra configuration step
The text was updated successfully, but these errors were encountered: