Skip to content

設定您的 EAP 版建置

最新的 Kotlin EAP 版本:2.2.0-RC

探索 Kotlin EAP 版本詳細資訊

要設定您的建置以使用 Kotlin 的 EAP 版本,您需要:

  • 指定 Kotlin 的 EAP 版本。可用的 EAP 版本列於此處
  • 將依賴項版本更改為 EAP 版本。 Kotlin 的 EAP 版本可能無法與先前發布版本的函式庫相容。

以下程序說明如何在 Gradle 和 Maven 中設定您的建置:

在 Gradle 中設定

本節說明如何:

調整 Kotlin 版本

build.gradle(.kts) 中的 plugins 區塊內,將 KOTLIN-EAP-VERSION 更改為實際的 EAP 版本, 例如 2.2.0-RC可用的 EAP 版本列於此處

或者,您可以在 settings.gradle(.kts) 中的 pluginManagement 區塊中指定 EAP 版本 – 請參閱 Gradle 文件 以獲取詳細資訊。

這是一個多平台專案的範例。

kotlin
plugins {
    java
    kotlin("multiplatform") version "KOTLIN-EAP-VERSION"
}

repositories {
    mavenCentral()
}
groovy
plugins {
    id 'java'
    id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN-EAP-VERSION'
}

repositories {
    mavenCentral()
}

調整依賴項中的版本

如果您在專案中使用 kotlinx 函式庫,您的函式庫版本可能與 Kotlin 的 EAP 版本不相容。

為了解決此問題,您需要在依賴項中指定相容函式庫的版本。有關相容函式庫的列表, 請參閱 EAP 建置詳細資訊

NOTE

在大多數情況下,我們僅為特定發布版的第一個 EAP 版本建立函式庫,並且這些函式庫可與該發布版的後續 EAP 版本一起使用。

如果在後續 EAP 版本中存在不相容的更改,我們將發布新版本的函式庫。

這是一個範例。

對於 kotlinx.coroutines 函式庫,請新增與 2.2.0-RC 相容的版本號 — 1.10.2

kotlin
dependencies {
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
}
groovy
dependencies {
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2"
}

在 Maven 中設定

在 Maven 專案定義範例中,將 KOTLIN-EAP-VERSION 替換為實際版本,例如 2.2.0-RC可用的 EAP 版本列於此處

xml
<project ...>
    <properties>
        <kotlin.version>KOTLIN-EAP-VERSION</kotlin.version>
    </properties>

    <repositories>
        <repository>
           <id>mavenCentral</id>
           <url>https://repo1.maven.org/maven2/</url>
        </repository>
    </repositories>

    <pluginRepositories>
       <pluginRepository>
          <id>mavenCentral</id>
          <url>https://repo1.maven.org/maven2/</url>
       </pluginRepository>
    </pluginRepositories>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                ...
            </plugin>
        </plugins>
    </build>
</project>

如果您遇到任何問題