配置构建采用 EAP

If you create new projects using the EAP version of Kotlin, you don’t need to perform any additional steps. The Kotlin Plugin will do everything for you!

You only need to configure your build manually for existing projects — projects that were created before installing the EAP version.

To configure your build to use the EAP version of Kotlin, you need to:

  • Specify the EAP version of Kotlin. Available EAP versions are listed here.
  • Change the versions of dependencies to EAP ones. The EAP version of Kotlin may not work with the libraries of the previously released version.

The following procedures describe how to configure your build in Gradle and Maven:

Configure in Gradle

This section describes how you can:

Adjust the Kotlin version

In the plugins block within build.gradle(.kts), change the KOTLIN-EAP-VERSION to the actual EAP version, such as 1.9.20-RC2. Available EAP versions are listed here.

Alternatively, you can specify the EAP version in the pluginManagement block in settings.gradle(.kts) – see Gradle documentation for details.

Here is an example for the Multiplatform project.

【Kotlin】

  1. plugins {
  2. java
  3. kotlin("multiplatform") version "KOTLIN-EAP-VERSION"
  4. }
  5. repositories {
  6. mavenCentral()
  7. }

【Groovy】

  1. plugins {
  2. id 'java'
  3. id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN-EAP-VERSION'
  4. }
  5. repositories {
  6. mavenCentral()
  7. }

Adjust versions in dependencies

If you use kotlinx libraries in your project, your versions of the libraries may not be compatible with the EAP version of Kotlin.

To resolve this issue, you need to specify the version of a compatible library in dependencies. For a list of compatible libraries, see EAP build details.

In most cases we create libraries only for the first EAP version of a specific release and these libraries work with the subsequent EAP versions for this release.

If there are incompatible changes in next EAP versions, we release a new version of the library.

配置构建采用 EAP - 图1

Here is an example.

For the kotlinx.coroutines library, add the version number – 1.7.1 – that is compatible with 1.9.20-RC2.

【Kotlin】

  1. dependencies {
  2. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
  3. }

【Groovy】

  1. dependencies {
  2. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1"
  3. }

Configure in Maven

In the sample Maven project definition, replace KOTLIN-EAP-VERSION with the actual version, such as 1.9.20-RC2. Available EAP versions are listed here.

  1. <project ...>
  2. <properties>
  3. <kotlin.version>KOTLIN-EAP-VERSION</kotlin.version>
  4. </properties>
  5. <repositories>
  6. <repository>
  7. <id>mavenCentral</id>
  8. <url>https://repo1.maven.org/maven2/</url>
  9. </repository>
  10. </repositories>
  11. <pluginRepositories>
  12. <pluginRepository>
  13. <id>mavenCentral</id>
  14. <url>https://repo1.maven.org/maven2/</url>
  15. </pluginRepository>
  16. </pluginRepositories>
  17. <dependencies>
  18. <dependency>
  19. <groupId>org.jetbrains.kotlin</groupId>
  20. <artifactId>kotlin-stdlib</artifactId>
  21. <version>${kotlin.version}</version>
  22. </dependency>
  23. </dependencies>
  24. <build>
  25. <plugins>
  26. <plugin>
  27. <groupId>org.jetbrains.kotlin</groupId>
  28. <artifactId>kotlin-maven-plugin</artifactId>
  29. <version>${kotlin.version}</version>
  30. ...
  31. </plugin>
  32. </plugins>
  33. </build>
  34. </project>