Skip to content

Add Dokka configuration method #2020

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

Merged
merged 2 commits into from
May 19, 2020
Merged
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
16 changes: 16 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import java.util.*

plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
maven("https://kotlin.bintray.com/kotlin-eap")
maven("https://kotlin.bintray.com/kotlin-dev")
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
}

val props = Properties().apply {
file("../gradle.properties").inputStream().use { load(it) }
}

fun version(target: String): String =
props.getProperty("${target}_version")

dependencies {
implementation(kotlin("gradle-plugin", version("kotlin")))
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${version("dokka")}")
}
23 changes: 23 additions & 0 deletions buildSrc/src/main/kotlin/Dokka.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.gradle.api.Project
import org.gradle.kotlin.dsl.delegateClosureOf
import org.gradle.kotlin.dsl.withType
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink.Builder
import org.jetbrains.dokka.gradle.DokkaTask
import java.io.File
import java.net.URL

fun Project.externalDocumentationLink(
url: String,
packageList: File = projectDir.resolve("package.list")
) {
tasks.withType<DokkaTask>().configureEach {
externalDocumentationLink(delegateClosureOf<Builder> {
this.url = URL(url)
packageListUrl = packageList.toPath().toUri().toURL()
})
}
}
47 changes: 19 additions & 28 deletions reactive/kotlinx-coroutines-reactive/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,33 @@
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
import org.jetbrains.dokka.gradle.DokkaTask
import java.net.URL

val reactiveStreamsVersion = property("reactive_streams_version")

dependencies {
compile("org.reactivestreams:reactive-streams:$reactiveStreamsVersion")
testCompile("org.reactivestreams:reactive-streams-tck:$reactiveStreamsVersion")
}

tasks {
val testNG = register<Test>("testNG") {
useTestNG()
reports.html.destination = file("$buildDir/reports/testng")
include("**/*ReactiveStreamTckTest.*")
// Skip testNG when tests are filtered with --tests, otherwise it simply fails
onlyIf {
filter.includePatterns.isEmpty()
}
doFirst {
// Classic gradle, nothing works without doFirst
println("TestNG tests: ($includes)")
}
val testNG by tasks.registering(Test::class) {
useTestNG()
reports.html.destination = file("$buildDir/reports/testng")
include("**/*ReactiveStreamTckTest.*")
// Skip testNG when tests are filtered with --tests, otherwise it simply fails
onlyIf {
filter.includePatterns.isEmpty()
}

named<Test>("test") {
reports.html.destination = file("$buildDir/reports/junit")

dependsOn(testNG)
doFirst {
// Classic gradle, nothing works without doFirst
println("TestNG tests: ($includes)")
}
}

withType<DokkaTask>().configureEach {
externalDocumentationLink(delegateClosureOf<ExternalDocumentationLink.Builder> {
url = URL("https://www.reactive-streams.org/reactive-streams-$reactiveStreamsVersion-javadoc/")
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
})
}
tasks.test {
reports.html.destination = file("$buildDir/reports/junit")

dependsOn(testNG)
}

externalDocumentationLink(
url = "https://www.reactive-streams.org/reactive-streams-$reactiveStreamsVersion-javadoc/"
)
13 changes: 3 additions & 10 deletions ui/kotlinx-coroutines-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
import org.jetbrains.dokka.gradle.DokkaTask
import java.net.URL

repositories {
google()
}
Expand Down Expand Up @@ -100,9 +96,6 @@ tasks.test {
}
}

tasks.withType<DokkaTask>().configureEach {
externalDocumentationLink(delegateClosureOf<ExternalDocumentationLink.Builder> {
url = URL("https://developer.android.com/reference/")
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
})
}
externalDocumentationLink(
url = "https://developer.android.com/reference/"
)