Skip to content

Commit

Permalink
Update to Dokka 2 (#1016)
Browse files Browse the repository at this point in the history
Instructions from https://kotlinlang.org/docs/dokka-migration.html

✅ ~Blocked on
vanniktech/gradle-maven-publish-plugin#854

<!--
  ⬆ Put your description above this! ⬆

  Please be descriptive and detailed.
  
Please read our [Contributing
Guidelines](https://github.com/tinyspeck/foundry/blob/main/.github/CONTRIBUTING.md)
and [Code of Conduct](https://slackhq.github.io/code-of-conduct).

Don't worry about deleting this, it's not visible in the PR!
-->
  • Loading branch information
ZacSweers authored Oct 14, 2024
1 parent 085bebe commit 5fb97cf
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ jobs:

- name: Publish snapshot
if: github.repository == 'slackhq/foundry'
run: ./gradlew publish -PmavenCentralUsername=${{ secrets.SONATYPEUSERNAME }} -PmavenCentralPassword=${{ secrets.SONATYPEPASSWORD }} -x dokkaHtml --no-configuration-cache
run: ./gradlew publish -PmavenCentralUsername=${{ secrets.SONATYPEUSERNAME }} -PmavenCentralPassword=${{ secrets.SONATYPEPASSWORD }}
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: gradle/actions/setup-gradle@v4

- name: Build Dokka API docs
run: dokkaHtml --no-configuration-cache
run: :dokkaGenerate

- name: Setup Python
uses: actions/setup-python@v5
Expand Down
53 changes: 29 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import dev.bmac.gradle.intellij.PluginUploader
import dev.bmac.gradle.intellij.UploadPluginTask
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import java.net.URI
import okio.ByteString.Companion.encode
import org.gradle.util.internal.VersionNumber
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformDependenciesExtension
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformExtension
import org.jetbrains.intellij.platform.gradle.tasks.BuildPluginTask
Expand Down Expand Up @@ -154,9 +154,20 @@ allprojects {
}
}

tasks.dokkaHtmlMultiModule {
outputDirectory.set(rootDir.resolve("docs/api/0.x"))
includes.from(project.layout.projectDirectory.file("README.md"))
dokka {
dokkaPublications.html {
outputDirectory.set(rootDir.resolve("docs/api/0.x"))
includes.from(project.layout.projectDirectory.file("README.md"))
}
}

dependencies {
dokka(projects.tools.cli)
dokka(projects.tools.foundryCommon)
dokka(projects.tools.skippy)
dokka(projects.tools.tracing)
dokka(projects.platforms.gradle.foundryGradlePlugin)
dokka(projects.platforms.gradle.agpHandlers.agpHandlerApi)
}

val kotlinVersion = libs.versions.kotlin.get()
Expand Down Expand Up @@ -268,43 +279,37 @@ subprojects {
pluginManager.withPlugin("com.vanniktech.maven.publish") {
apply(plugin = "org.jetbrains.dokka")

tasks.withType<DokkaTaskPartial>().configureEach {
outputDirectory.set(layout.buildDirectory.dir("docs/partial"))
configure<DokkaExtension> {
dokkaPublicationDirectory.set(layout.buildDirectory.dir("dokkaDir"))
dokkaSourceSets.configureEach {
val readMeProvider = project.layout.projectDirectory.file("README.md")
if (readMeProvider.asFile.exists()) {
includes.from(readMeProvider)
}
documentedVisibilities.add(VisibilityModifier.Public)
skipDeprecated.set(true)
if (isForGradle) {
// Gradle docs
externalDocumentationLink {
url.set(
URI("https://docs.gradle.org/${gradle.gradleVersion}/javadoc/index.html").toURL()
)
externalDocumentationLinks.register("Gradle") {
packageListUrl("https://docs.gradle.org/${gradle.gradleVersion}/javadoc/element-list")
url("https://docs.gradle.org/${gradle.gradleVersion}/javadoc")
}
// AGP docs
externalDocumentationLink {
externalDocumentationLinks.register("AGP") {
val agpVersionNumber = VersionNumber.parse(libs.versions.agp.get()).baseVersion
val simpleApi = "${agpVersionNumber.major}.${agpVersionNumber.minor}"
packageListUrl.set(
URI(
"https://developer.android.com/reference/tools/gradle-api/$simpleApi/package-list"
)
.toURL()
)
url.set(
URI("https://developer.android.com/reference/tools/gradle-api/$simpleApi/classes")
.toURL()
packageListUrl(
"https://developer.android.com/reference/tools/gradle-api/$simpleApi/package-list"
)
url("https://developer.android.com/reference/tools/gradle-api/$simpleApi/classes")
}
}
sourceLink {
localDirectory.set(layout.projectDirectory.dir("src").asFile)
localDirectory.set(layout.projectDirectory.dir("src"))
val relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
remoteUrl.set(
remoteUrl(
providers.gradleProperty("POM_SCM_URL").map { scmUrl ->
URI("$scmUrl/tree/main/$relPath/src").toURL()
"$scmUrl/tree/main/$relPath/src"
}
)
remoteLineSuffix.set("#L")
Expand Down
2 changes: 1 addition & 1 deletion deploy_website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if ! [[ ${local} || ${ci} ]]; then
# Move working directory into temp folder
cd ${DIR}
# Generate the API docs
./gradlew dokkaHtmlMultiModule --no-configuration-cache
./gradlew :dokkaGenerate
fi

# Copy in special files that GitHub wants in the project root.
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ kotlin.compiler.preciseCompilationResultsBackup=true

moshix.generateProguardRules=false

# Dokka flags
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

ksp.useKSP2=true

# The IJ platform gradle plugin does this silly thing where it checks for updates at configuration-time
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ coroutines = "1.9.0"
coroutines-ij = "1.9.0"
dependencyAnalysisPlugin = "2.1.4"
detekt = "1.23.7"
dokka = "1.9.20"
dokka = "2.0.0-Beta"
errorproneGradle = "4.0.1"
gradle-retry = "1.6.0"
graph-assert = "2.7.1"
Expand Down
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ git commit -am "Prepare for release $NEW_VERSION."
git tag -a "$NEW_VERSION" -m "Version $NEW_VERSION"

# Publish
./gradlew publish -x dokkaHtml --no-configuration-cache -PSONATYPE_CONNECT_TIMEOUT_SECONDS=300
./gradlew publish --no-configuration-cache -PSONATYPE_CONNECT_TIMEOUT_SECONDS=300

# Prepare next snapshot
echo "Restoring snapshot version $SNAPSHOT_VERSION"
Expand Down

0 comments on commit 5fb97cf

Please sign in to comment.