Skip to content

Commit b5e36c4

Browse files
authored
Merge pull request #2020 from turansky/dokka-external-links
Add Dokka configuration method
2 parents 1eeed50 + 1dc1db3 commit b5e36c4

File tree

4 files changed

+61
-38
lines changed

4 files changed

+61
-38
lines changed

buildSrc/build.gradle.kts

+16
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1+
import java.util.*
2+
13
plugins {
24
`kotlin-dsl`
35
}
46

57
repositories {
68
gradlePluginPortal()
9+
maven("https://kotlin.bintray.com/kotlin-eap")
10+
maven("https://kotlin.bintray.com/kotlin-dev")
711
}
812

913
kotlinDslPluginOptions {
1014
experimentalWarning.set(false)
1115
}
16+
17+
val props = Properties().apply {
18+
file("../gradle.properties").inputStream().use { load(it) }
19+
}
20+
21+
fun version(target: String): String =
22+
props.getProperty("${target}_version")
23+
24+
dependencies {
25+
implementation(kotlin("gradle-plugin", version("kotlin")))
26+
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${version("dokka")}")
27+
}

buildSrc/src/main/kotlin/Dokka.kt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import org.gradle.api.Project
6+
import org.gradle.kotlin.dsl.delegateClosureOf
7+
import org.gradle.kotlin.dsl.withType
8+
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink.Builder
9+
import org.jetbrains.dokka.gradle.DokkaTask
10+
import java.io.File
11+
import java.net.URL
12+
13+
fun Project.externalDocumentationLink(
14+
url: String,
15+
packageList: File = projectDir.resolve("package.list")
16+
) {
17+
tasks.withType<DokkaTask>().configureEach {
18+
externalDocumentationLink(delegateClosureOf<Builder> {
19+
this.url = URL(url)
20+
packageListUrl = packageList.toPath().toUri().toURL()
21+
})
22+
}
23+
}

reactive/kotlinx-coroutines-reactive/build.gradle.kts

+19-28
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,33 @@
22
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
6-
import org.jetbrains.dokka.gradle.DokkaTask
7-
import java.net.URL
8-
95
val reactiveStreamsVersion = property("reactive_streams_version")
106

117
dependencies {
128
compile("org.reactivestreams:reactive-streams:$reactiveStreamsVersion")
139
testCompile("org.reactivestreams:reactive-streams-tck:$reactiveStreamsVersion")
1410
}
1511

16-
tasks {
17-
val testNG = register<Test>("testNG") {
18-
useTestNG()
19-
reports.html.destination = file("$buildDir/reports/testng")
20-
include("**/*ReactiveStreamTckTest.*")
21-
// Skip testNG when tests are filtered with --tests, otherwise it simply fails
22-
onlyIf {
23-
filter.includePatterns.isEmpty()
24-
}
25-
doFirst {
26-
// Classic gradle, nothing works without doFirst
27-
println("TestNG tests: ($includes)")
28-
}
12+
val testNG by tasks.registering(Test::class) {
13+
useTestNG()
14+
reports.html.destination = file("$buildDir/reports/testng")
15+
include("**/*ReactiveStreamTckTest.*")
16+
// Skip testNG when tests are filtered with --tests, otherwise it simply fails
17+
onlyIf {
18+
filter.includePatterns.isEmpty()
2919
}
30-
31-
named<Test>("test") {
32-
reports.html.destination = file("$buildDir/reports/junit")
33-
34-
dependsOn(testNG)
20+
doFirst {
21+
// Classic gradle, nothing works without doFirst
22+
println("TestNG tests: ($includes)")
3523
}
24+
}
3625

37-
withType<DokkaTask>().configureEach {
38-
externalDocumentationLink(delegateClosureOf<ExternalDocumentationLink.Builder> {
39-
url = URL("https://www.reactive-streams.org/reactive-streams-$reactiveStreamsVersion-javadoc/")
40-
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
41-
})
42-
}
26+
tasks.test {
27+
reports.html.destination = file("$buildDir/reports/junit")
28+
29+
dependsOn(testNG)
4330
}
31+
32+
externalDocumentationLink(
33+
url = "https://www.reactive-streams.org/reactive-streams-$reactiveStreamsVersion-javadoc/"
34+
)

ui/kotlinx-coroutines-android/build.gradle.kts

+3-10
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
6-
import org.jetbrains.dokka.gradle.DokkaTask
7-
import java.net.URL
8-
95
repositories {
106
google()
117
}
@@ -100,9 +96,6 @@ tasks.test {
10096
}
10197
}
10298

103-
tasks.withType<DokkaTask>().configureEach {
104-
externalDocumentationLink(delegateClosureOf<ExternalDocumentationLink.Builder> {
105-
url = URL("https://developer.android.com/reference/")
106-
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
107-
})
108-
}
99+
externalDocumentationLink(
100+
url = "https://developer.android.com/reference/"
101+
)

0 commit comments

Comments
 (0)