Skip to content

Migrate to DGPv2 #4436

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

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
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
11 changes: 6 additions & 5 deletions buildSrc/src/main/kotlin/Dokka.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.gradle.api.*
import org.gradle.api.publish.PublishingExtension
import org.gradle.kotlin.dsl.*
import org.jetbrains.dokka.gradle.*
import org.jetbrains.dokka.gradle.DokkaExtension
import java.io.*
import java.net.*

Expand All @@ -11,11 +12,11 @@ fun Project.externalDocumentationLink(
url: String,
packageList: File = projectDir.resolve("package.list")
) {
tasks.withType<AbstractDokkaLeafTask>().configureEach {
extensions.configure<DokkaExtension> {
dokkaSourceSets.configureEach {
externalDocumentationLink {
this.url = URL(url)
packageListUrl = packageList.toPath().toUri().toURL()
externalDocumentationLinks.register("api") {
this.url = URI.create(url)
this.packageListUrl = packageList.toURI()
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/UnpackAar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import java.util.zip.ZipFile
val artifactType = Attribute.of("artifactType", String::class.java)
val unpackedAar = Attribute.of("unpackedAar", Boolean::class.javaObjectType)

fun Project.configureAar() = configurations.configureEach {
afterEvaluate {
if (isCanBeResolved && !isCanBeConsumed) {
fun Project.configureAar() {
configurations
.matching { it.isCanBeResolved && !it.isCanBeConsumed }
.configureEach {
attributes.attribute(unpackedAar, true) // request all AARs to be unpacked
}
}
}

fun DependencyHandlerScope.configureAarUnpacking() {
Expand Down
77 changes: 23 additions & 54 deletions buildSrc/src/main/kotlin/dokka-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.jetbrains.dokka.gradle.*
import java.net.*


Expand All @@ -7,75 +6,45 @@ plugins {
}

val knit_version: String by project
private val projetsWithoutDokka = unpublished + "kotlinx-coroutines-bom" + jdk8ObsoleteModule
private val coreModuleDocsUrl = "https://kotlinlang.org/api/kotlinx.coroutines/$coreModule/"
private val coreModuleDocsPackageList = "$projectDir/kotlinx-coroutines-core/build/dokka/htmlPartial/package-list"
private val projectsWithoutDokka = unpublished + "kotlinx-coroutines-bom" + jdk8ObsoleteModule
private val subprojectWithDokka = subprojects.filterNot { projectsWithoutDokka.contains(it.name) }

configure(subprojects.filterNot { projetsWithoutDokka.contains(it.name) }) {
configure(subprojectWithDokka) {
apply(plugin = "org.jetbrains.dokka")
configurePathsaver()
configureDokkaTemplatesDir()
condigureDokkaSetup()
configureExternalLinks()
}

// Setup top-level 'dokkaHtmlMultiModule' with templates
tasks.withType<DokkaMultiModuleTask>().named("dokkaHtmlMultiModule") {
setupDokkaTemplatesDir(this)
}
// For top-level multimodule collection
configurePathsaver()
configureDokkaTemplatesDir()

dependencies {
// Add explicit dependency between Dokka and Knit plugin
add("dokkaHtmlMultiModulePlugin", "org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
subprojectWithDokka.forEach {
dokka(it)
}
}

// Dependencies for Knit processing: Knit plugin to work with Dokka
private fun Project.configurePathsaver() {
tasks.withType(DokkaTaskPartial::class).configureEach {
dependencies {
plugins("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
}
dependencies {
dokkaPlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
}
}

// Configure Dokka setup
private fun Project.condigureDokkaSetup() {
tasks.withType(DokkaTaskPartial::class).configureEach {
suppressInheritedMembers = true
setupDokkaTemplatesDir(this)

dokka {
dokkaPublications.configureEach {
suppressInheritedMembers = true
}
dokkaSourceSets.configureEach {
jdkVersion = 11
includes.from("README.md")
noStdlibLink = true

externalDocumentationLink {
url = URL("https://kotlinlang.org/api/latest/jvm/stdlib/")
packageListUrl = rootProject.projectDir.toPath().resolve("site/stdlib.package.list").toUri().toURL()
}

// Something suspicious to figure out, probably legacy of earlier days
if (!project.isMultiplatform) {
dependsOn(project.configurations["compileClasspath"])
}
}

// Source links
dokkaSourceSets.configureEach {
sourceLink {
localDirectory = rootDir
remoteUrl = URL("https://github.com/kotlin/kotlinx.coroutines/tree/master")
remoteLineSuffix ="#L"
}
}
}
}

private fun Project.configureExternalLinks() {
tasks.withType<DokkaTaskPartial>() {
dokkaSourceSets.configureEach {
externalDocumentationLink {
url = URL(coreModuleDocsUrl)
packageListUrl = File(coreModuleDocsPackageList).toURI().toURL()
remoteUrl("https://github.com/kotlin/kotlinx.coroutines/tree/master")
}
}
}
Expand All @@ -90,10 +59,10 @@ private fun Project.configureExternalLinks() {
* - Template setup: https://github.com/JetBrains/kotlin-web-site/blob/master/.teamcity/builds/apiReferences/kotlinx/coroutines/KotlinxCoroutinesPrepareDokkaTemplates.kt
* - Templates repository: https://github.com/JetBrains/kotlin-web-site/tree/master/dokka-templates
*/
private fun Project.setupDokkaTemplatesDir(dokkaTask: AbstractDokkaTask) {
dokkaTask.pluginsMapConfiguration = mapOf(
"org.jetbrains.dokka.base.DokkaBase" to """{ "templatesDir" : "${
project.rootProject.projectDir.toString().replace('\\', '/')
}/dokka-templates" }"""
)
private fun Project.configureDokkaTemplatesDir() {
dokka {
pluginsConfiguration.html {
templatesDir = rootDir.resolve("dokka-templates")
}
}
}
14 changes: 4 additions & 10 deletions buildSrc/src/main/kotlin/knit-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ plugins {
knit {
siteRoot = "https://kotlinlang.org/api/kotlinx.coroutines"
moduleRoots = listOf(".", "integration", "reactive", "ui")
moduleDocs = "build/dokka/htmlPartial"
dokkaMultiModuleRoot = "build/dokka/htmlMultiModule/"
moduleDocs = "build/dokka-module/html/module"
dokkaMultiModuleRoot = "build/dokka/html/"
}

tasks.named("knitPrepare").configure {
val knitTask = this
// In order for knit to operate, it should depend on and collect
// all Dokka outputs from each module
allprojects {
val dokkaTasks = tasks.matching { it.name == "dokkaHtmlMultiModule" }
knitTask.dependsOn(dokkaTasks)
}
tasks.named("knitPrepare") {
dependsOn("dokkaGenerate")
}
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ junit_version=4.12
junit5_version=5.7.0
knit_version=0.5.0
lincheck_version=2.18.1
dokka_version=1.9.20
dokka_version=2.0.0
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.nowarn=true

byte_buddy_version=1.10.9
reactor_version=3.4.1
reactor_docs_version=3.4.5
Expand Down
3 changes: 2 additions & 1 deletion kotlinx-coroutines-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.gradle.kotlin.dsl.*
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.dokka.gradle.tasks.DokkaBaseTask
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
import org.jetbrains.kotlin.gradle.tasks.*
Expand Down Expand Up @@ -287,7 +288,7 @@ artifacts {
}

// Workaround for https://github.com/Kotlin/dokka/issues/1833: make implicit dependency explicit
tasks.named("dokkaHtmlPartial") {
tasks.withType<DokkaBaseTask>() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adam-enko, this is still required. Could you check what happens here?

dependsOn(jvmJar)
}

Expand Down
12 changes: 1 addition & 11 deletions reactive/kotlinx-coroutines-rx2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import java.net.*

dependencies {
api(project(":kotlinx-coroutines-reactive"))
testImplementation("org.reactivestreams:reactive-streams-tck:${version("reactive_streams")}")
api("io.reactivex.rxjava2:rxjava:${version("rxjava2")}")
}

tasks.withType(DokkaTaskPartial::class) {
dokkaSourceSets.configureEach {
externalDocumentationLink {
url = URL("http://reactivex.io/RxJava/2.x/javadoc/")
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
}
}
}
externalDocumentationLink("http://reactivex.io/RxJava/2.x/javadoc/")

val testNG by tasks.registering(Test::class) {
useTestNG()
Expand Down
12 changes: 1 addition & 11 deletions reactive/kotlinx-coroutines-rx3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import java.net.*

dependencies {
api(project(":kotlinx-coroutines-reactive"))
testImplementation("org.reactivestreams:reactive-streams-tck:${version("reactive_streams")}")
api("io.reactivex.rxjava3:rxjava:${version("rxjava3")}")
}

tasks.withType(DokkaTaskPartial::class) {
dokkaSourceSets.configureEach {
externalDocumentationLink {
url = URL("https://reactivex.io/RxJava/3.x/javadoc/")
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
}
}
}
externalDocumentationLink("http://reactivex.io/RxJava/3.x/javadoc/")

val testNG by tasks.registering(Test::class) {
useTestNG()
Expand Down
Loading