Skip to content

Commit 0e4baf3

Browse files
Merge pull request #1383 from square/sedwards/upgrade-dokka
1319: Use Dokka Plugin v2
2 parents b6e70a0 + fc3e3c3 commit 0e4baf3

File tree

12 files changed

+85
-100
lines changed

12 files changed

+85
-100
lines changed

.buildscript/deploy_snapshot.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

artifacts.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
[
2-
{
3-
"gradlePath": ":internal-testing-utils",
4-
"group": "com.squareup.workflow1",
5-
"artifactId": "workflow-internal-testing-utils",
6-
"description": "Workflow internal testing utilities",
7-
"packaging": "jar",
8-
"javaVersion": 8,
9-
"publicationName": "maven"
10-
},
112
{
123
"gradlePath": ":trace-encoder",
134
"group": "com.squareup.workflow1",

build-logic/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ gradlePlugin {
3737
id = "dependency-guard"
3838
implementationClass = "com.squareup.workflow1.buildsrc.DependencyGuardConventionPlugin"
3939
}
40+
create("dokka") {
41+
id = "dokka"
42+
implementationClass = "com.squareup.workflow1.buildsrc.DokkaConfigPlugin"
43+
}
4044
create("kotlin-android") {
4145
id = "kotlin-android"
4246
implementationClass = "com.squareup.workflow1.buildsrc.KotlinAndroidConventionPlugin"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.squareup.workflow1.buildsrc
2+
3+
import org.gradle.api.Plugin
4+
import org.gradle.api.Project
5+
import org.jetbrains.dokka.gradle.DokkaExtension
6+
7+
class DokkaConfigPlugin : Plugin<Project> {
8+
override fun apply(target: Project) {
9+
target.plugins.apply("org.jetbrains.dokka")
10+
11+
target.extensions.configure(DokkaExtension::class.java) { dokka ->
12+
dokka.dokkaSourceSets.configureEach { sourceSet ->
13+
sourceSet.reportUndocumented.set(false)
14+
sourceSet.skipDeprecated.set(true)
15+
16+
val sourceSetName = sourceSet.name
17+
18+
if (target.file("src/$sourceSetName").exists()) {
19+
20+
val readmeFile = target.file("${target.projectDir}/README.md")
21+
// If the module has a README, add it to the module's index
22+
if (readmeFile.exists()) {
23+
sourceSet.includes.from(readmeFile)
24+
}
25+
26+
sourceSet.sourceLink {
27+
it.localDirectory.set(target.file("src/$sourceSetName"))
28+
29+
val modulePath = target.projectDir.relativeTo(target.rootDir).path
30+
31+
// URL showing where the source code can be accessed through the web browser
32+
it.remoteUrl("https://github.com/square/workflow-kotlin/blob/main/$modulePath/src/$sourceSetName")
33+
// Suffix which is used to append the line number to the URL. Use #L for GitHub
34+
it.remoteLineSuffix.set("#L")
35+
}
36+
}
37+
sourceSet.perPackageOption {
38+
// Will match all .internal packages and sub-packages, regardless of module.
39+
it.matchingRegex.set(""".*\.internal.*""")
40+
it.suppress.set(true)
41+
}
42+
}
43+
}
44+
}
45+
}

build-logic/src/main/java/com/squareup/workflow1/buildsrc/PublishingConventionPlugin.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.squareup.workflow1.buildsrc
22

3+
import com.rickbusarow.kgx.libsCatalog
4+
import com.rickbusarow.kgx.pluginId
35
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
46
import com.vanniktech.maven.publish.JavadocJar
57
import com.vanniktech.maven.publish.KotlinJvm
@@ -14,7 +16,8 @@ import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
1416

1517
class PublishingConventionPlugin : Plugin<Project> {
1618
override fun apply(target: Project) {
17-
target.plugins.apply("org.jetbrains.dokka")
19+
20+
target.plugins.apply("dokka")
1821
target.plugins.apply("com.vanniktech.maven.publish.base")
1922
// track all runtime classpath dependencies for anything we ship
2023
target.plugins.apply("dependency-guard")
@@ -64,15 +67,15 @@ class PublishingConventionPlugin : Plugin<Project> {
6467
target.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
6568
basePluginExtension.configure(
6669
KotlinJvm(
67-
javadocJar = JavadocJar.Dokka(taskName = "dokkaGfm"),
70+
javadocJar = JavadocJar.Dokka(taskName = "dokkaGeneratePublicationHtml"),
6871
sourcesJar = true
6972
)
7073
)
7174
target.setPublicationProperties(pomDescription, artifactId)
7275
}
7376
target.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
7477
basePluginExtension.configure(
75-
KotlinMultiplatform(javadocJar = JavadocJar.Dokka(taskName = "dokkaGfm"))
78+
KotlinMultiplatform(javadocJar = JavadocJar.Dokka(taskName = "dokkaGeneratePublicationHtml"))
7679
)
7780
// don't set the artifactId for KMP, because this is handled by the KMP plugin itself
7881
target.setPublicationProperties(pomDescription, artifactIdOrNull = null)

build.gradle.kts

Lines changed: 24 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import com.squareup.workflow1.buildsrc.shardConnectedCheckTasks
22
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
3-
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
4-
import java.net.URL
53

64
buildscript {
75
dependencies {
@@ -27,6 +25,7 @@ plugins {
2725
base
2826
id("artifacts-check")
2927
id("dependency-guard")
28+
alias(libs.plugins.dokka)
3029
alias(libs.plugins.ktlint)
3130
alias(libs.plugins.compose.compiler) apply false
3231
}
@@ -35,63 +34,29 @@ shardConnectedCheckTasks(project)
3534

3635
apply(from = rootProject.file(".buildscript/binary-validation.gradle"))
3736

38-
// This plugin needs to be applied to the root projects for the dokkaGfmCollector task we use to
39-
// generate the documentation site.
40-
apply(plugin = "org.jetbrains.dokka")
41-
42-
// Configuration that applies to all dokka tasks, both those used for generating javadoc artifacts
43-
// and the documentation site.
44-
subprojects {
45-
tasks.withType<AbstractDokkaLeafTask> {
46-
47-
// This is the displayed name for the module, like in the Html sidebar.
48-
// artifact id: workflow-internal-testing-utils
49-
// path: internal-testing-utils
50-
moduleName.set(
51-
provider {
52-
findProperty("POM_ARTIFACT_ID") as? String
53-
?: project.path.removePrefix(":")
54-
}
55-
)
56-
57-
dokkaSourceSets.configureEach {
58-
59-
val dokkaSourceSet = this
60-
61-
reportUndocumented.set(false)
62-
skipDeprecated.set(true)
63-
64-
if (file("src/${dokkaSourceSet.name}").exists()) {
65-
66-
val readmeFile = file("$projectDir/README.md")
67-
// If the module has a README, add it to the module's index
68-
if (readmeFile.exists()) {
69-
includes.from(readmeFile)
70-
}
71-
72-
sourceLink {
73-
localDirectory.set(file("src/${dokkaSourceSet.name}"))
74-
75-
val modulePath = projectDir.relativeTo(rootDir).path
37+
dependencies {
38+
dokka(project(":workflow-core"))
39+
dokka(project(":workflow-runtime"))
40+
dokka(project(":workflow-runtime-android"))
41+
dokka(project(":workflow-rx2"))
42+
dokka(project(":workflow-testing"))
43+
dokka(project(":workflow-ui:compose"))
44+
dokka(project(":workflow-ui:compose-tooling"))
45+
dokka(project(":workflow-ui:core-android"))
46+
dokka(project(":workflow-ui:core-common"))
47+
dokka(project(":workflow-ui:radiography"))
48+
}
7649

77-
// URL showing where the source code can be accessed through the web browser
78-
remoteUrl.set(
79-
@Suppress("ktlint:standard:max-line-length")
80-
URL(
81-
"https://github.com/square/workflow-kotlin/blob/main/$modulePath/src/${dokkaSourceSet.name}"
82-
)
83-
)
84-
// Suffix which is used to append the line number to the URL. Use #L for GitHub
85-
remoteLineSuffix.set("#L")
86-
}
87-
}
88-
perPackageOption {
89-
// Will match all .internal packages and sub-packages, regardless of module.
90-
matchingRegex.set(""".*\.internal.*""")
91-
suppress.set(true)
92-
}
50+
dokka {
51+
// This is the displayed name for the module, like in the Html sidebar.
52+
// artifact id: workflow-internal-testing-utils
53+
// path: internal-testing-utils
54+
moduleName.set(
55+
provider {
56+
findProperty("POM_ARTIFACT_ID") as? String
57+
?: project.path.removePrefix(":")
9358
}
94-
}
59+
)
9560
}
9661

9762
// Publish tasks use the output of Sign tasks, but don't actually declare a dependency upon it,
@@ -118,11 +83,11 @@ subprojects {
11883
tasks.register<Copy>("siteDokka") {
11984
description = "Generate dokka Html for the documentation site."
12085
group = "documentation"
121-
dependsOn(":dokkaHtmlMultiModule")
86+
dependsOn(":dokkaGenerate")
12287

12388
// Copy the files instead of configuring a different output directory on the dokka task itself
12489
// since the default output directories disambiguate between different types of outputs, and our
12590
// custom directory doesn't.
126-
from(layout.buildDirectory.file("dokka/htmlMultiModule/workflow"))
91+
from(layout.buildDirectory.file("dokka/html"))
12792
into(layout.buildDirectory.file("dokka/workflow"))
12893
}

dependencies/classpath.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ org.glassfish.jaxb:txw2:2.3.2
143143
org.jdom:jdom2:2.0.6
144144
org.jetbrains.dokka:dokka-core:2.0.0
145145
org.jetbrains.dokka:dokka-gradle-plugin:2.0.0
146+
org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:2.0.0
146147
org.jetbrains.intellij.deps:trove4j:1.0.20200330
147148
org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:2.0.21
148149
org.jetbrains.kotlin:compose-compiler-gradle-plugin:2.0.21

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ POM_DEVELOPER_NAME=Square, Inc.
2626
POM_DEVELOPER_URL=https://github.com/square/
2727
SONATYPE_STAGING_PROFILE=com.squareup
2828

29+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
30+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
31+
2932
kotlin.languageVersion=1.9

internal-testing-utils/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id("kotlin-jvm")
3-
id("published")
43
}
54

65
dependencies {

workflow-runtime/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.squareup.workflow1.buildsrc.iosWithSimulatorArm64
2+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
23

34
plugins {
45
id("kotlin-multiplatform")
@@ -20,6 +21,7 @@ kotlin {
2021

2122
// Needed for expect class Lock, which is not public API, so this doesn't add any binary compat
2223
// risk.
24+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
2325
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")
2426
}
2527

0 commit comments

Comments
 (0)