Skip to content

Commit

Permalink
README: Hide old Gradle plugin instructions, clear up setup flow (#2470)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianAigner authored Oct 12, 2023
1 parent 9dab3f4 commit ba38b70
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ Kotlin serialization consists of a compiler plugin, that generates visitor code
* [Introduction and references](#introduction-and-references)
* [Setup](#setup)
* [Gradle](#gradle)
* [Using the `plugins` block](#using-the-plugins-block)
* [Using `apply plugin` (the old way)](#using-apply-plugin-the-old-way)
* [Dependency on the JSON library](#dependency-on-the-json-library)
* [Setting up the serialization plugin](#1-setting-up-the-serialization-plugin)
* [Dependency on the JSON library](#2-dependency-on-the-json-library)
* [Android](#android)
* [Multiplatform (Common, JS, Native)](#multiplatform-common-js-native)
* [Maven](#maven)
Expand Down Expand Up @@ -83,9 +82,13 @@ Make sure you have the corresponding Kotlin plugin installed in the IDE, no addi

### Gradle

#### Using the `plugins` block
To set up kotlinx.serialization, you have to do two things:
1) Add the **[serialization plugin](#1-setting-up-the-serialization-plugin)**.
2) Add the **[serialization library dependency](#2-dependency-on-the-json-library)**.

You can set up the serialization plugin with the Kotlin plugin using
#### 1) Setting up the serialization plugin

You can set up the serialization plugin with the Kotlin plugin using the
[Gradle plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block):

Kotlin DSL:
Expand All @@ -106,9 +109,10 @@ plugins {
}
```

> Kotlin versions before 1.4.0 are not supported by the stable release of Kotlin serialization
> Kotlin versions before 1.4.0 are not supported by the stable release of Kotlin serialization.
#### Using `apply plugin` (the old way)
<details>
<summary>Using <code>apply plugin</code> (the old way)</summary>

First, you have to add the serialization plugin to your classpath as the other [compiler plugins](https://kotlinlang.org/docs/reference/compiler-plugins.html):

Expand Down Expand Up @@ -145,10 +149,11 @@ Then you can `apply plugin` (example in Groovy):
apply plugin: 'kotlin' // or 'kotlin-multiplatform' for multiplatform projects
apply plugin: 'kotlinx-serialization'
```
</details>

#### Dependency on the JSON library
#### 2) Dependency on the JSON library

After setting up the plugin one way or another, you have to add a dependency on the serialization library.
After setting up the plugin, you have to add a dependency on the serialization library.
Note that while the plugin has version the same as the compiler one, runtime library has different coordinates, repository and versioning.

Kotlin DSL:
Expand Down

0 comments on commit ba38b70

Please sign in to comment.