Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Kotlin versions to 2.0.0-RC1 #3516

Merged
merged 16 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
### Java
*.class

# new Kotlin 2.0 state dir
.kotlin/

# Package Files #
*.jar
*.war
Expand Down
2 changes: 1 addition & 1 deletion dokka-integration-tests/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ testing {
registerTestProjectSuite(
"testTemplateProjectAndroid",
"it-android-0",
jvm = JavaLanguageVersion.of(11), // AGP requires JVM 11+
jvm = JavaLanguageVersion.of(17), // AGP requires JVM 17+
)
registerTestProjectSuite("testTemplateProjectBasic", "it-basic")
registerTestProjectSuite("testTemplateProjectBasicGroovy", "it-basic-groovy")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
dokka_it_android_gradle_plugin_version=4.2.2
android.useAndroidX=true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
fail_on_warning=false
report_undocumented=false
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
react_version=18.2.0-pre.467
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
task_number=100
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.22
dokka_it_kotlin_version=2.0.0-RC1
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,30 @@ dependencyResolutionManagement {
}

// Declare Kotlin/Native dependencies - workaround for https://youtrack.jetbrains.com/issue/KT-51379
exclusiveContent {
forRepository {
ivy("https://download.jetbrains.com/kotlin/native/builds") {
name = "Kotlin Native"
patternLayout {
// Remove this repo when the only supported KGP version is above 2.0.0
ivy("https://download.jetbrains.com/kotlin/native/builds") {
name = "Kotlin Native"
patternLayout {

// example download URLs:
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/linux-x86_64/kotlin-native-prebuilt-linux-x86_64-1.7.20.tar.gz
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/windows-x86_64/kotlin-native-prebuilt-windows-x86_64-1.7.20.zip
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/macos-x86_64/kotlin-native-prebuilt-macos-x86_64-1.7.20.tar.gz
listOf(
"macos-x86_64",
"macos-aarch64",
"osx-x86_64",
"osx-aarch64",
"linux-x86_64",
"windows-x86_64"
).forEach { os ->
listOf("dev", "releases").forEach { stage ->
artifact("$stage/[revision]/$os/[artifact]-[revision].[ext]")
}
}
// example download URLs:
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/linux-x86_64/kotlin-native-prebuilt-linux-x86_64-1.7.20.tar.gz
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/windows-x86_64/kotlin-native-prebuilt-windows-x86_64-1.7.20.zip
// https://download.jetbrains.com/kotlin/native/builds/releases/1.7.20/macos-x86_64/kotlin-native-prebuilt-macos-x86_64-1.7.20.tar.gz
listOf(
"macos-x86_64",
"macos-aarch64",
"osx-x86_64",
"osx-aarch64",
"linux-x86_64",
"windows-x86_64"
).forEach { os ->
listOf("dev", "releases").forEach { stage ->
artifact("$stage/[revision]/$os/[artifact]-[revision].[ext]")
}
metadataSources { artifact() }
}
}
filter { includeModuleByRegex(".*", ".*kotlin-native-prebuilt.*") }
metadataSources { artifact() }
content { includeModuleByRegex(".*", ".*kotlin-native-prebuilt.*") }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ abstract class AbstractGradleIntegrationTest : AbstractIntegrationTest() {
vararg arguments: String,
jvmArgs: List<String> = listOf("-Xmx2G", "-XX:MaxMetaspaceSize=1G")
): GradleRunner {

// TODO quick hack to add `android { namespace }` on AGP 7+ (it's mandatory in 8+).
whyoleg marked this conversation as resolved.
Show resolved Hide resolved
// This hack could be made prettier, or only test AGP 7+
val androidMajorVersion = buildVersions.androidGradlePluginVersion
?.substringBefore(".")
?.toIntOrNull() ?: 0
if (androidMajorVersion >= 7) {
projectDir.resolve("build.gradle.kts").appendText(
"""
|
|android {
| namespace = "org.jetbrains.dokka.it.android"
|}
|
""".trimMargin()
)
}

return GradleRunner.create()
.withProjectDir(projectDir)
.forwardOutput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open class AllSupportedTestedVersionsArgumentsProvider : TestedVersionsArguments

object TestedVersions {

val LATEST = BuildVersions("7.6.2", "1.9.22")
val LATEST = BuildVersions("8.7", "2.0.0-RC1")

/**
* All supported Gradle/Kotlin versions, including [LATEST]
Expand All @@ -24,7 +24,7 @@ object TestedVersions {
val ALL_SUPPORTED =
BuildVersions.permutations(
gradleVersions = listOf("7.6.2"),
kotlinVersions = listOf("1.9.10", "1.8.20", "1.7.20", "1.6.21", "1.5.31"),
kotlinVersions = listOf("1.9.23", "1.8.20", "1.7.20", "1.6.21", "1.5.31"),
) + BuildVersions.permutations(
gradleVersions = listOf(*ifExhaustive("7.0", "6.1.1")),
kotlinVersions = listOf(*ifExhaustive( "1.8.0", "1.7.0", "1.6.0", "1.5.0"))
Expand All @@ -40,14 +40,18 @@ object TestedVersions {
*/
val ANDROID =
BuildVersions.permutations(
gradleVersions = listOf("8.4"),
kotlinVersions = listOf("2.0.0-RC1"),
androidGradlePluginVersions = listOf("8.3.0")
) + BuildVersions.permutations(
gradleVersions = listOf("7.4.2", *ifExhaustive("7.0")),
kotlinVersions = listOf("1.7.20", "1.6.21", "1.5.31", "1.4.32"),
androidGradlePluginVersions = listOf("7.2.0")
) + BuildVersions.permutations(
gradleVersions = listOf("6.9", *ifExhaustive("6.1.1", "5.6.4")),
kotlinVersions = listOf("1.8.0", "1.7.0", "1.6.0", "1.5.0", "1.4.0"),
androidGradlePluginVersions = listOf("4.0.0", *ifExhaustive("3.6.3"))
) + LATEST
)

// https://mvnrepository.com/artifact/org.jetbrains.kotlin-wrappers/kotlin-react
val KT_REACT_WRAPPER_MAPPING = mapOf(
Expand All @@ -61,8 +65,8 @@ object TestedVersions {
"1.8.20" to "18.2.0-pre.546",
"1.9.0" to "18.2.0-pre.597",
"1.9.10" to "18.2.0-pre.597",
"1.9.20" to "18.2.0-pre.635",
"1.9.22" to "18.2.0-pre.682",
"1.9.23" to "18.2.0-pre.682",
"2.0.0-RC1" to "18.2.0-pre.726",
)
}

Expand Down
2 changes: 1 addition & 1 deletion dokka-integration-tests/maven/projects/it-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<version>1.0-SNAPSHOT</version>

<properties>
<kotlin.version>1.9.22</kotlin.version>
<kotlin.version>2.0.0-RC1</kotlin.version>
</properties>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
@file:Suppress("INVISIBLE_REFERENCE")
package org.jetbrains.dokka.gradle.kotlin

import java.io.File
import org.gradle.api.Project
import org.jetbrains.kotlin.commonizer.KonanDistribution
import org.jetbrains.kotlin.commonizer.platformLibsDir
import org.jetbrains.kotlin.commonizer.stdlib
import org.jetbrains.kotlin.compilerRunner.konanHome
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
import org.jetbrains.kotlin.konan.target.KonanTarget
import java.io.File

/**
* Provides access to the Kotlin/Native distribution components:
Expand All @@ -27,12 +27,23 @@ internal class KotlinNativeDistributionAccessor(
project: Project
) {
private val konanDistribution = KonanDistribution(
@Suppress("INVISIBLE_MEMBER")
project.konanHome
// see this comment for the explanation of what's happening:
whyoleg marked this conversation as resolved.
Show resolved Hide resolved
// https://github.com/Kotlin/dokka/pull/3516#issuecomment-1992141380
Class.forName("org.jetbrains.kotlin.compilerRunner.NativeToolRunnersKt")
.declaredMethods
.find { it.name == "getKonanHome" && it.returnType.simpleName == "String" }
?.invoke(null, project) as? String
?: project.alternativeKonanHome()
?: error("Unable to find the Kotlin Native home")
)

val stdlibDir: File = konanDistribution.stdlib

private fun Project.alternativeKonanHome(): String? {
val nativeHome = this.findProperty("org.jetbrains.kotlin.native.home") as? String ?: return null
return File(nativeHome).absolutePath ?: NativeCompilerDownloader(project).compilerDirectory.absolutePath
}

fun platformDependencies(target: KonanTarget): List<File> = konanDistribution
.platformLibsDir
.resolve(target.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

package org.jetbrains.dokka.gradle.kotlin

import com.android.build.gradle.api.ApplicationVariant
import com.android.build.gradle.api.LibraryVariant
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
Expand All @@ -22,7 +20,9 @@ private fun isMainCompilation(compilation: KotlinCompilation): Boolean {
try {
val androidVariant = compilation.run { this as? KotlinJvmAndroidCompilation }?.androidVariant
if (androidVariant != null) {
return androidVariant is LibraryVariant || androidVariant is ApplicationVariant
@Suppress("DEPRECATION")
return androidVariant is com.android.build.gradle.api.LibraryVariant
|| androidVariant is com.android.build.gradle.api.ApplicationVariant
}
} catch (e: NoSuchMethodError) {
// Kotlin Plugin version below 1.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ private fun KotlinCompilation.newCompileClasspathOf(project: Project): FileColle
// Since Kotlin 2.0 native distributiuon dependencies will be included to compileDependencyFiles
if (kgpVersion != null && kgpVersion <= KotlinGradlePluginVersion(1, 9, 255)) {
if (this is AbstractKotlinNativeCompilation) {
val kotlinNativeDistributionAccessor = KotlinNativeDistributionAccessor(project)
result.from(kotlinNativeDistributionAccessor.stdlibDir)
result.from(kotlinNativeDistributionAccessor.platformDependencies(konanTarget))
val excludePlatformFiles = project.classpathProperty("excludeKonanPlatformDependencyFiles", default = false)
if (!excludePlatformFiles) {
val kotlinNativeDistributionAccessor = KotlinNativeDistributionAccessor(project)
result.from(kotlinNativeDistributionAccessor.stdlibDir)
result.from(kotlinNativeDistributionAccessor.platformDependencies(konanTarget))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,45 @@ import org.gradle.api.internal.project.ProjectInternal
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.withType
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.gradle.utils.isAgpRunnable
import kotlin.test.*

class AndroidAutoConfigurationTest {

private val project = ProjectBuilder.builder().build().also { project ->
project.plugins.apply("com.android.library")
project.plugins.apply("org.jetbrains.kotlin.android")
project.plugins.apply("org.jetbrains.dokka")
project.extensions.configure<LibraryExtension> {
compileSdkVersion(28)
if (isAgpRunnable()) {
project.plugins.apply("com.android.library")
project.plugins.apply("org.jetbrains.kotlin.android")
project.plugins.apply("org.jetbrains.dokka")
project.extensions.configure<LibraryExtension> {
compileSdk = 28
}
}
}

@Test
fun `at least one dokka task created`() {
if (!isAgpRunnable()) return

val dokkaTasks = project.tasks.withType<DokkaTask>().toList()
assertTrue(dokkaTasks.isNotEmpty(), "Expected at least one dokka task")
}

@Test
fun `all default source sets are present in dokka`() {
if (!isAgpRunnable()) return

val dokkaTasks = project.tasks.withType<DokkaTask>().toList()
dokkaTasks.forEach { task ->
val sourceSets = task.dokkaSourceSets.toList()
val sourceSets = task.dokkaSourceSets.map { it.name }.toSet()
assertEquals(
listOf(
"androidTest", "androidTestDebug", "debug", "main",
"release", "test", "testDebug", "testRelease", "androidTestRelease"
).sorted(),
sourceSets.map { it.name }.sorted(),
setOf(
"main", "debug", "release",
"test", "testDebug", "testRelease",
"androidTest", "androidTestDebug", "androidTestRelease",
"testFixtures", "testFixturesDebug", "testFixturesRelease"
),
sourceSets,
"Expected all default source sets being registered"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.closureOf
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.*
import org.jetbrains.dokka.gradle.utils.isAgpRunnable
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
import java.net.URI
import kotlin.test.*
Expand Down Expand Up @@ -398,6 +399,8 @@ class GradleDokkaSourceSetBuilderTest {

@Test
fun noAndroidSdkLink() {
if (!isAgpRunnable()) return

val sourceSet = GradleDokkaSourceSetBuilder("", project)
assertFalse(sourceSet.noAndroidSdkLink.get(), "Expected 'noAndroidSdkLink' to be set to false by default")

Expand Down