You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documentation from the docs folder is incorporated into a common story that spans six chapters and proceeds from the basic serialization to the experimental alternative and custom formats. The example files are automatically generated from the text with the Knit tool (guide/example folder) and are verified with the automatically generated tests (guide/test folder).
The entry point to the new is docs/serialization-guide.md that contains the overall table of contents and links to the specific chapters.
The old docs that are being incorporated:
* cbor_byte_string.md -> formats.md
* custom_serializers.md -> serializers.md
* examples.md -> basic-serialization.md
* json_transformations.md -> json.md
* old12.md (removed completely as obsolete)
* runtime_usage.md -> various chapters
Additional changes include:
* Top-level README.md file is cleaned up from legacy information and also contains a modern knitted example.
* More consistent error messages in various exceptions.
* Minor corrections to KDocs and APIs.
* Better style.css for the documentation that is generated by Dokka.
* Improved update_docs.sh to put temporary files inside the build folder.
Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
Kotlin serialization consists of a compiler plugin, that generates visitor code for serializable classes,
9
-
runtime library with core serialization API and JSON format, and support libraries with ProtoBuf, CBOR and properties formats.
9
+
runtime libraries with core serialization API and JSON format, and support libraries with ProtoBuf, CBOR and properties formats.
10
10
11
11
* Supports Kotlin classes marked as `@Serializable` and standard collections.
12
-
* Provides JSON, [CBOR](formats/README.md#CBOR), and [Protobuf](formats/README.md#ProtoBuf) formats.
12
+
* Provides JSON (as a part of the core library), [Protobuf](formats/README.md#ProtoBuf), [CBOR](formats/README.md#CBOR), [Hocon](formats/README.md#HOCON)and [Properties](formats/README.md#properties) formats.
13
13
* Complete multiplatform support: JVM, JS and Native.
To learn more about JSON usage and other formats, see [usage](docs/runtime_usage.md).
75
-
More examples of various kinds of Kotlin classes that can be serialized can be found [here](docs/examples.md).
76
-
77
-
## Current project status
78
-
79
-
Starting from Kotlin 1.3-RC2, serialization plugin is shipped with the rest of Kotlin compiler distribution, and the IDEA plugin is bundled into the Kotlin plugin.
80
-
81
-
Runtime library is under reconstruction to match the corresponding [KEEP](https://github.com/Kotlin/KEEP/blob/serialization/proposals/extensions/serialization.md), so some features described there can be not implemented yet. While library is stable and has successfully been used in various scenarios, there is no API compatibility guarantees between versions, that's why it is called experimental.
82
-
This document describes setup for Kotlin 1.3 and higher. To watch instructions regarding 1.2, follow [this document](docs/old12.md).
62
+
**Read the [Kotlin Serialization Guide](docs/serialization-guide.md) for all details.**
83
63
84
64
## Setup
85
65
86
-
Using Kotlin Serialization requires Kotlin compiler `1.3.30` or higher.
87
-
Make sure that you have corresponding Kotlin plugin installed in the IDE.
88
-
Since serialization is now bundled into Kotlin plugin, no additional plugins for IDE are required (but make sure you have deleted old additional plugin for 1.2, if you had one).
66
+
Kotlin serialization plugin is shipped with the Kotlin compiler distribution, and the IDEA plugin is bundled into the Kotlin plugin.
67
+
68
+
Using Kotlin Serialization requires Kotlin compiler `1.4.0` or higher.
69
+
Make sure you have the corresponding Kotlin plugin installed in the IDE, no additional plugins for IDE are required.
89
70
Example projects on JVM are available for [Gradle](examples/example-jvm/build.gradle) and [Maven](examples/example-jvm/pom.xml).
90
71
91
72
### Gradle
92
73
93
74
#### Using the `plugins` block
94
75
95
-
You can setup the serialization plugin with the Kotlin plugin using [Gradle plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block):
76
+
You can set up the serialization plugin with the Kotlin plugin using
kotlin("multiplatform") // or kotlin("jvm") or any other kotlin plugin
102
-
kotlin("plugin.serialization") version "1.3.70"
83
+
kotlin("jvm") version "1.4.0"// or kotlin("multiplatform") or any other kotlin plugin
84
+
kotlin("plugin.serialization") version "1.4.0"
103
85
}
104
-
```
86
+
```
87
+
105
88
Groovy DSL:
106
89
107
90
```gradle
108
91
plugins {
109
-
id 'org.jetbrains.kotlin.multiplatform' version '1.3.70' // or any other kotlin plugin
110
-
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.70'
92
+
id 'org.jetbrains.kotlin.multiplatform' version '1.4.0'
93
+
id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.0'
111
94
}
112
95
```
113
96
114
-
Note: plugin marker for serialization has been published in Kotlin 1.3.50. If you need to use the earlier Kotlin version, see [KT-27612](https://youtrack.jetbrains.com/issue/KT-27612) for workaround with [plugin resolution rules](https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_resolution_rules).
97
+
> Kotlin versions before are not supported by the stable release of Kotlin serialization
115
98
116
99
#### Using `apply plugin` (the old way)
117
100
@@ -124,7 +107,7 @@ buildscript {
124
107
repositories { jcenter() }
125
108
126
109
dependencies {
127
-
val kotlinVersion ="1.3.70"
110
+
val kotlinVersion ="1.4.0"
128
111
classpath(kotlin("gradle-plugin", version = kotlinVersion))
129
112
classpath(kotlin("serialization", version = kotlinVersion))
130
113
}
@@ -135,7 +118,7 @@ Groovy DSL:
135
118
136
119
```gradle
137
120
buildscript {
138
-
ext.kotlin_version = '1.3.70'
121
+
ext.kotlin_version = '1.4.0'
139
122
repositories { jcenter() }
140
123
141
124
dependencies {
@@ -165,7 +148,7 @@ repositories {
165
148
166
149
dependencies {
167
150
implementation(kotlin("stdlib", KotlinCompilerVersion.VERSION)) // or "stdlib-jdk8"
Library versions `0.20.0` and higher require Kotlin 1.3.70 and higher and incompatible with previous versions.
312
-
313
-
Library version `0.14.0` require Kotlin 1.3.60/61 and incompatible with other versions.
314
-
315
-
All versions of library before `0.13.0` are using Gradle metadata v0.4 and therefore it is recommended to use Gradle 4.8-5.1 to build.
316
-
317
-
Library versions `0.11.0` and higher require Kotlin 1.3.30 and higher and incompatible with previous versions.
318
-
319
-
All versions of library before `0.10.0` are using Gradle metadata v0.3 and therefore require Gradle 4.7 for build.
320
-
321
-
Maven plugin coordinates before Kotlin 1.3.20 were `kotlinx-maven-serialization-plugin`.
322
-
323
-
324
-
## Troubleshooting IntelliJ IDEA
325
-
326
-
Serialization support should work out of the box, if you have `1.3.x` Kotlin plugin installed and have imported the project from Maven or Gradle with serialization enabled in their build scripts.
327
-
If you have Kotlin `1.3.10` or lower, you have to delegate build to Gradle (`Settings - Build, Execution, Deployment - Build Tools - Gradle - Runner -` tick `Delegate IDE build/run actions to gradle`).
328
-
Starting from `1.3.11`, no delegation is required.
329
-
In case of problems, force project re-import from Gradle.
0 commit comments