1*57b5a4a6SAndroid Build Coastguard Worker# Building Kotlin Serialization from the source 2*57b5a4a6SAndroid Build Coastguard Worker 3*57b5a4a6SAndroid Build Coastguard Worker## JDK version 4*57b5a4a6SAndroid Build Coastguard Worker 5*57b5a4a6SAndroid Build Coastguard WorkerTo build Kotlin Serialization JDK version 11 or higher is required. Make sure this is your default JDK (`JAVA_HOME` is set accordingly). 6*57b5a4a6SAndroid Build Coastguard WorkerThis is needed to compile the `module-info` file included for JPMS support. 7*57b5a4a6SAndroid Build Coastguard Worker 8*57b5a4a6SAndroid Build Coastguard WorkerIn case you are determined to use different JDK version, or experience problems with JPMS you can turn off compilation of modules 9*57b5a4a6SAndroid Build Coastguard Workercompletely with `disableJPMS` property: add `disableJPMS=true` to gradle.properties or `-PdisableJPMS` to Gradle CLI invocation. 10*57b5a4a6SAndroid Build Coastguard Worker 11*57b5a4a6SAndroid Build Coastguard Worker## Runtime library 12*57b5a4a6SAndroid Build Coastguard Worker 13*57b5a4a6SAndroid Build Coastguard WorkerKotlin Serialization runtime library itself is a [multiplatform](http://kotlinlang.org/docs/reference/multiplatform.html) project. 14*57b5a4a6SAndroid Build Coastguard WorkerTo build library from the source and run all tests, use `./gradlew build`. Corresponding platform tasks like `jvmTest`, `jsTest`, `nativeTest` and so on are also available. 15*57b5a4a6SAndroid Build Coastguard Worker 16*57b5a4a6SAndroid Build Coastguard WorkerProject can be opened in in Intellij IDEA without additional prerequisites. 17*57b5a4a6SAndroid Build Coastguard WorkerIn case you want to work with Protobuf tests, you may need to run `./gradlew generateTestProto` beforehand. 18*57b5a4a6SAndroid Build Coastguard Worker 19*57b5a4a6SAndroid Build Coastguard Worker 20*57b5a4a6SAndroid Build Coastguard WorkerTo install runtime library into the local Maven repository, run `./gradlew publishToMavenLocal`. 21*57b5a4a6SAndroid Build Coastguard WorkerAfter that, you can include this library in arbitrary projects like usual gradle dependency: 22*57b5a4a6SAndroid Build Coastguard Worker 23*57b5a4a6SAndroid Build Coastguard Worker```gradle 24*57b5a4a6SAndroid Build Coastguard Workerrepositories { 25*57b5a4a6SAndroid Build Coastguard Worker mavenLocal() 26*57b5a4a6SAndroid Build Coastguard Worker} 27*57b5a4a6SAndroid Build Coastguard Worker 28*57b5a4a6SAndroid Build Coastguard Workerdependencies { 29*57b5a4a6SAndroid Build Coastguard Worker compile "org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version" 30*57b5a4a6SAndroid Build Coastguard Worker} 31*57b5a4a6SAndroid Build Coastguard Worker``` 32*57b5a4a6SAndroid Build Coastguard Worker 33*57b5a4a6SAndroid Build Coastguard WorkerNote that by default, only one Native target is built (the one that is the current host, e.g. `macosX64` on Intel Mac machines, `linuxX64` on linux machines, etc). 34*57b5a4a6SAndroid Build Coastguard WorkerTo compile and publish all Native artifacts, not only the host one, use Gradle property `native.deploy=true`. 35*57b5a4a6SAndroid Build Coastguard Worker 36*57b5a4a6SAndroid Build Coastguard WorkerTo use snapshot version of compiler (if you have built and install it from sources), use flag `-Pbootstrap`. 37*57b5a4a6SAndroid Build Coastguard WorkerIf you have built both Kotlin and Kotlin/Native compilers, set `KONAN_LOCAL_DIST` environment property to the path with Kotlin/Native distribution 38*57b5a4a6SAndroid Build Coastguard Worker(usually `kotlin-native/dist` folder inside Kotlin project). 39*57b5a4a6SAndroid Build Coastguard Worker 40*57b5a4a6SAndroid Build Coastguard Worker`master` and `dev` branches of library should be binary compatible with latest released compiler plugin. In case you want to test some new features from other branches, 41*57b5a4a6SAndroid Build Coastguard Workerwhich are still in development and may not be compatible in terms of bytecode produced by plugin, you'll need to build the plugin by yourself. 42*57b5a4a6SAndroid Build Coastguard Worker 43*57b5a4a6SAndroid Build Coastguard Worker## Compiler plugin 44*57b5a4a6SAndroid Build Coastguard Worker 45*57b5a4a6SAndroid Build Coastguard WorkerCompiler plugin for Gradle/Maven and IntelliJ plugin, starting from Kotlin 1.3, are embedded into the Kotlin compiler. 46*57b5a4a6SAndroid Build Coastguard Worker 47*57b5a4a6SAndroid Build Coastguard WorkerSources and steps to build it are located [here](https://github.com/JetBrains/kotlin/tree/master/plugins/kotlinx-serialization). 48*57b5a4a6SAndroid Build Coastguard WorkerIn short, you'll just need to run `./gradlew dist install` to get `1.x.255-SNAPSHOT` versions of Kotlin compiler, stdlib and serialization plugins in the Maven local repository. 49