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

Test with KGP 2.1.0-RC #3898

Draft
wants to merge 4 commits into
base: compiler-2.1.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*/

import dokkabuild.utils.excludeGradleEmbeddedDependencies
import org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
Expand All @@ -12,10 +14,13 @@ plugins {
}

kotlin {
@OptIn(ExperimentalBuildToolsApi::class, ExperimentalKotlinGradlePluginApi::class)
compilerVersion = libs.versions.gradlePlugin.kotlin.compiler
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
compilerOptions {
// Must use Kotlin 1.4 to support Gradle 7
languageVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_4
apiVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_4
languageVersion = KotlinVersion.KOTLIN_1_4
apiVersion = KotlinVersion.KOTLIN_1_4
}
}

Expand Down
8 changes: 8 additions & 0 deletions build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
id("dokkabuild.java")
kotlin("jvm")
Expand All @@ -11,6 +14,11 @@ val rootProjectsWithoutDependencyOnDokkaCore = listOf("dokka-integration-tests")

kotlin {
explicitApi()

if (dokkaBuild.kotlinLanguageLevel.isPresent) {
@OptIn(ExperimentalBuildToolsApi::class, ExperimentalKotlinGradlePluginApi::class)
compilerVersion = libs.versions.gradlePlugin.kotlin.compiler
}
compilerOptions {
allWarningsAsErrors = true
languageVersion = dokkaBuild.kotlinLanguageLevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pluginManagement {
}
repositories {
/* %{DOKKA_IT_MAVEN_REPO}% */
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
mavenCentral()
gradlePluginPortal()
google()
Expand All @@ -49,7 +48,6 @@ dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
/* %{DOKKA_IT_MAVEN_REPO}% */
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
mavenCentral()
google()
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ abstract class AbstractGradleIntegrationTest : AbstractIntegrationTest() {

/* language=kts */
"""
|maven { setUrl("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") }
|exclusiveContent {
| forRepositories(
| $reposSpecs
Expand Down
15 changes: 0 additions & 15 deletions dokka-runners/dokka-gradle-plugin/api/dokka-gradle-plugin.api
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,6 @@ public abstract class org/jetbrains/dokka/gradle/engine/parameters/DokkaGenerato
public abstract fun getSuppressObviousFunctions ()Lorg/gradle/api/provider/Property;
}

public final class org/jetbrains/dokka/gradle/engine/parameters/DokkaModuleDescriptionKxs$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lorg/jetbrains/dokka/gradle/engine/parameters/DokkaModuleDescriptionKxs$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lorg/jetbrains/dokka/gradle/engine/parameters/DokkaModuleDescriptionKxs;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lorg/jetbrains/dokka/gradle/engine/parameters/DokkaModuleDescriptionKxs;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
}

public final class org/jetbrains/dokka/gradle/engine/parameters/DokkaModuleDescriptionKxs$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public abstract class org/jetbrains/dokka/gradle/engine/parameters/DokkaPackageOptionsSpec : java/io/Serializable, org/jetbrains/dokka/gradle/engine/parameters/HasConfigurableVisibilityModifiers {
public abstract fun getDocumentedVisibilities ()Lorg/gradle/api/provider/SetProperty;
public abstract fun getMatchingRegex ()Lorg/gradle/api/provider/Property;
Expand Down
6 changes: 5 additions & 1 deletion dokka-runners/dokka-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import dokkabuild.utils.skipTestFixturesPublications
plugins {
id("dokkabuild.gradle-plugin")

kotlin("plugin.serialization") version embeddedKotlinVersion
// fails with back-end exception no matter which version is used
// probably related to the fact that we use `kotlin.compiler.runViaBuildToolsApi`
// kotlin("plugin.serialization") version embeddedKotlinVersion // doesn't work
// kotlin("plugin.serialization") version "2.0.20" // doesn't work
// kotlin("plugin.serialization") version "2.1.0-RC-330" // doesn't work

`jvm-test-suite`
`java-test-fixtures`
Expand Down
1 change: 1 addition & 0 deletions dokka-runners/dokka-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ version=2.0.20-SNAPSHOT
org.jetbrains.dokka.javaToolchain.mainCompiler=8
org.jetbrains.dokka.javaToolchain.testLauncher=8
org.jetbrains.dokka.kotlinLanguageLevel=1.4
kotlin.compiler.runViaBuildToolsApi=true

# Gradle settings
org.gradle.jvmargs=-Dfile.encoding=UTF-8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
*/
package org.jetbrains.dokka.gradle.engine.parameters

import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.jsonPrimitive
import kotlinx.serialization.json.put
import org.gradle.kotlin.dsl.java
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.gradle.internal.InternalDokkaGradlePluginApi
Expand All @@ -23,7 +26,6 @@ import org.jetbrains.dokka.gradle.internal.InternalDokkaGradlePluginApi
* @see org.jetbrains.dokka.gradle.engine.parameters.DokkaModuleDescriptionKxs
* @see org.jetbrains.dokka.DokkaModuleDescriptionImpl
*/
@Serializable
@InternalDokkaGradlePluginApi
data class DokkaModuleDescriptionKxs(
/** @see DokkaConfiguration.DokkaModuleDescription.name */
Expand All @@ -34,4 +36,20 @@ data class DokkaModuleDescriptionKxs(
val moduleOutputDirName: String = "module",
/** name of the sibling directory that contains the module includes */
val moduleIncludesDirName: String = "includes",
)
) {
internal companion object {
fun toJsonObject(module: DokkaModuleDescriptionKxs): JsonObject = buildJsonObject {
put("name", module.name)
put("modulePath", module.modulePath)
put("moduleOutputDirName", module.moduleOutputDirName)
put("moduleIncludesDirName", module.moduleIncludesDirName)
}

fun fromJsonObject(obj: JsonObject): DokkaModuleDescriptionKxs = DokkaModuleDescriptionKxs(
name = obj["name"]!!.jsonPrimitive.content,
modulePath = obj["modulePath"]!!.jsonPrimitive.content,
moduleOutputDirName = obj["moduleOutputDirName"]!!.jsonPrimitive.content,
moduleIncludesDirName = obj["moduleIncludesDirName"]!!.jsonPrimitive.content,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
package org.jetbrains.dokka.gradle.engine.parameters.builders

import kotlinx.serialization.json.JsonObject
import org.gradle.api.Project
import org.gradle.api.file.ArchiveOperations
import org.gradle.api.file.FileCollection
Expand Down Expand Up @@ -96,9 +97,11 @@ internal class DokkaParametersBuilder(
}

val moduleDescriptor: DokkaModuleDescriptionKxs =
DokkaBasePlugin.jsonMapper.decodeFromString(
DokkaModuleDescriptionKxs.serializer(),
moduleDescriptorJson.readText(),
DokkaModuleDescriptionKxs.fromJsonObject(
DokkaBasePlugin.jsonMapper.decodeFromString(
JsonObject.serializer(),
moduleDescriptorJson.readText(),
)
)

val moduleOutputDirectory = moduleDir.resolve(moduleDescriptor.moduleOutputDirName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
package org.jetbrains.dokka.gradle.tasks

import kotlinx.serialization.json.JsonObject
import org.gradle.api.file.ArchiveOperations
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.model.ObjectFactory
Expand Down Expand Up @@ -87,8 +88,8 @@ constructor(

val encodedModuleDesc =
DokkaBasePlugin.jsonMapper.encodeToString(
DokkaModuleDescriptionKxs.serializer(),
moduleDesc
JsonObject.serializer(),
DokkaModuleDescriptionKxs.toJsonObject(moduleDesc)
)

logger.info("encodedModuleDesc: $encodedModuleDesc".lines().joinToString(" "))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class GradleProjectTest(
|pluginManagement {
| repositories {
|${dokkaTestRepo.prependIndent(" ")}
| maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
| mavenCentral()
| gradlePluginPortal()
| }
Expand All @@ -215,7 +214,6 @@ class GradleProjectTest(
|dependencyResolutionManagement {
| repositories {
|${dokkaTestRepo.prependIndent(" ")}
| maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
| mavenCentral()
| }
|}
Expand Down Expand Up @@ -250,6 +248,7 @@ class GradleProjectTest(
}

"""
|maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
|exclusiveContent {
| forRepositories(
| $reposSpecs
Expand Down
1 change: 1 addition & 0 deletions dokka-runners/runner-cli/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ version=2.0.20-SNAPSHOT
org.jetbrains.dokka.javaToolchain.mainCompiler=8
org.jetbrains.dokka.javaToolchain.testLauncher=8
org.jetbrains.dokka.kotlinLanguageLevel=1.4
kotlin.compiler.runViaBuildToolsApi=true
1 change: 1 addition & 0 deletions dokka-runners/runner-maven-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ version=2.0.20-SNAPSHOT
org.jetbrains.dokka.javaToolchain.mainCompiler=8
org.jetbrains.dokka.javaToolchain.testLauncher=8
org.jetbrains.dokka.kotlinLanguageLevel=1.4
kotlin.compiler.runViaBuildToolsApi=true
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ version=2.0.20-SNAPSHOT
org.jetbrains.dokka.javaToolchain.mainCompiler=8
org.jetbrains.dokka.javaToolchain.testLauncher=8
org.jetbrains.dokka.kotlinLanguageLevel=1.4
kotlin.compiler.runViaBuildToolsApi=true

# Code style
kotlin.code.style=official
Expand Down
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[versions]

gradlePlugin-kotlin = "2.0.20"
gradlePlugin-kotlin = "2.1.0-RC-330"
# We use a different compiler version to use Kotlin Language/API version 1.4 to compile modules
# to be able to be compatible with Gradle 7.
gradlePlugin-kotlin-compiler = "2.0.20"
# See: https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin
gradlePlugin-android = "7.1.3"
gradlePlugin-dokka = "1.9.20"
Expand Down
Loading