Skip to content

Commit acb9cf7

Browse files
committed
update: update Maven dependencies
1 parent e869afa commit acb9cf7

File tree

2 files changed

+62
-5
lines changed

2 files changed

+62
-5
lines changed

docs/topics/maven.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,21 @@ specify the ID and URL of each repository in the `<repositories>` element:
5656

5757
## Set dependencies
5858

59-
Kotlin has an extensive standard library that can be used in your applications.
59+
To add a dependency on a library, include it in the `<dependencies>` element:
60+
61+
```xml
62+
<dependencies>
63+
<dependency>
64+
<groupId>org.jetbrains.kotlinx</groupId>
65+
<artifactId>kotlinx-serialization-json</artifactId>
66+
<version>%serializationVersion%</version>
67+
</dependency>
68+
</dependencies>
69+
```
70+
71+
### Dependency on the standard library
72+
73+
Kotlin has an extensive standard library that you can use in your applications.
6074
To use the standard library in your project, add the following dependency to your `pom.xml` file:
6175

6276
```xml
@@ -75,13 +89,56 @@ To use the standard library in your project, add the following dependency to you
7589
> * 1.8, use `kotlin-stdlib-jdk7` or `kotlin-stdlib-jdk8`, respectively.
7690
> * 1.2, use `kotlin-stdlib-jre7` or `kotlin-stdlib-jre8`, respectively.
7791
>
78-
{style="note"}
92+
{style="note"}
93+
94+
### Dependencies on test libraries
7995

8096
If your project uses [Kotlin reflection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect.full/index.html)
81-
or testing facilities, you need to add the corresponding dependencies as well.
82-
The artifact IDs are `kotlin-reflect` for the reflection library, and `kotlin-test` and `kotlin-test-junit`
97+
or testing frameworks, add the relevant dependencies.
98+
Use `kotlin-reflect` for the reflection library, and `kotlin-test` and `kotlin-test-junit`
8399
for the testing libraries.
84100

101+
For example:
102+
103+
```xml
104+
<dependencies>
105+
<dependency>
106+
<groupId>org.jetbrains.kotlin</groupId>
107+
<artifactId>kotlin-reflect</artifactId>
108+
<version>${kotlin.version}</version>
109+
</dependency>
110+
</dependencies>
111+
```
112+
113+
### Dependency on a kotlinx library
114+
115+
Depending on the kotlinx library, you can either add the base artifact name or the name with a `-jvm` suffix. Refer to
116+
the library's README file on [klibs.io](https://klibs.io/).
117+
118+
For example, to add a dependency on `kotlinx.coroutines`:
119+
120+
```xml
121+
<dependencies>
122+
<dependency>
123+
<groupId>org.jetbrains.kotlinx</groupId>
124+
<artifactId>kotlinx-coroutines-core</artifactId>
125+
<version>%coroutinesVersion%</version>
126+
</dependency>
127+
</dependencies>
128+
```
129+
130+
To add a dependency on `kotlinx-datetime`:
131+
132+
```xml
133+
<dependencies>
134+
<dependency>
135+
<groupId>org.jetbrains.kotlinx</groupId>
136+
<artifactId>kotlinx-datetime-jvm</artifactId>
137+
<version>%dateTimeVersion%</version>
138+
</dependency>
139+
</dependencies>
140+
```
141+
85142
## Compile Kotlin-only source code
86143

87144
To compile source code, specify the source directories in the `<build>` tag:

docs/topics/releases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Alternatively, you can change the version of the `kotlin-maven-plugin` in your `
101101
```
102102

103103
If you have projects created with earlier Kotlin versions, check if you also need to [update the version of any kotlinx
104-
libraries](maven.md#set-dependencies).
104+
libraries](maven.md#dependency-on-a-kotlinx-library).
105105

106106
> To learn more about how to work with Maven in your project, see [Maven](maven.md).
107107
>

0 commit comments

Comments
 (0)