Skip to content

Commit

Permalink
Update to Dokka 2 (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers authored Oct 18, 2024
1 parent 553a67e commit 5919286
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 18 deletions.
37 changes: 27 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
import com.android.build.api.dsl.Lint
import com.google.devtools.ksp.gradle.KspTask
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import java.net.URI
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlinJvm) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.dokka)
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.spotless)
alias(libs.plugins.kotlinBinaryCompatibilityValidator)
Expand All @@ -44,6 +43,13 @@ apiValidation {
)
}

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

val ktfmtVersion = libs.versions.ktfmt.get()

spotless {
Expand Down Expand Up @@ -108,15 +114,13 @@ subprojects {
}
pluginManager.withPlugin("com.vanniktech.maven.publish") {
apply(plugin = "org.jetbrains.dokka")
tasks.named<DokkaTask>("dokkaHtml") {
outputDirectory.set(rootProject.rootDir.resolve("docs/0.x"))
configure<DokkaExtension> {
dokkaPublicationDirectory.set(layout.buildDirectory.dir("dokkaDir"))
dokkaSourceSets.configureEach {
skipDeprecated.set(true)
externalDocumentationLink {
url.set(URI("https://square.github.io/okio/2.x/okio/").toURL())
}
externalDocumentationLink {
url.set(URI("https://square.github.io/moshi/1.x/moshi/").toURL())
externalDocumentationLinks {
register("okio") { url("https://square.github.io/okio/2.x/okio/") }
register("moshi") { url("https://square.github.io/moshi/1.x/moshi/") }
}
}
}
Expand All @@ -136,3 +140,16 @@ subprojects {
}
}
}

dependencies {
dokka(projects.moshiAdapters)
dokka(projects.moshiImmutableAdapters)
dokka(projects.moshiIr.moshiCompilerPlugin)
dokka(projects.moshiMetadataReflect)
dokka(projects.moshiProguardRuleGen)
dokka(projects.moshiSealed.codegen)
dokka(projects.moshiSealed.javaSealedReflect)
dokka(projects.moshiSealed.metadataReflect)
dokka(projects.moshiSealed.reflect)
dokka(projects.moshiSealed.runtime)
}
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ ksp.version.check=false
kotlin.compiler.suppressExperimentalICOptimizationsWarning=true
kotlin.compiler.keepIncrementalCompilationCachesInMemory=true
kotlin.compiler.preciseCompilationResultsBackup=true

# Dokka flags
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ okhttp = "4.12.0"
retrofit = "2.11.0"

[plugins]
dokka = { id = "org.jetbrains.dokka", version = "1.9.20" }
dokka = { id = "org.jetbrains.dokka", version = "2.0.0-Beta" }
kotlinBinaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.16.3" }
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
Expand Down
8 changes: 5 additions & 3 deletions moshi-ir/moshi-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import com.vanniktech.maven.publish.MavenPublishBaseExtension
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand Down Expand Up @@ -80,8 +79,11 @@ gradlePlugin {
}
}

tasks.named<DokkaTask>("dokkaHtml") {
outputDirectory.set(rootProject.file("../docs/0.x"))
dokka {
dokkaPublications.html {
outputDirectory.set(rootDir.resolve("docs/api/0.x"))
includes.from(project.layout.projectDirectory.file("README.md"))
}
dokkaSourceSets.configureEach { skipDeprecated.set(true) }
}

Expand Down
4 changes: 4 additions & 0 deletions moshi-ir/moshi-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ POM_PACKAGING=jar
# Gradle imposes its own
kotlin.stdlib.default.dependency=false

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

GROUP=dev.zacsweers.moshix
VERSION_NAME=0.29.0-SNAPSHOT
POM_DESCRIPTION=A Kotlin compiler plugin that generates Moshi JsonAdapter classes.
Expand Down
5 changes: 5 additions & 0 deletions moshi-ir/moshi-gradle-plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ dependencyResolutionManagement {
google()
}
}

rootProject.name = "moshi-gradle-plugin"

// https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:type-safe-project-accessors
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
8 changes: 4 additions & 4 deletions publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
if [[ "$1" = "--local" ]]; then local=true; fi

if ! [[ ${local} ]]; then
./gradlew -p moshi-ir/moshi-gradle-plugin publish -x dokkaHtml --no-configuration-cache
./gradlew publish -x dokkaHtml --no-configuration-cache
./gradlew -p moshi-ir/moshi-gradle-plugin publish --no-configuration-cache
./gradlew publish --no-configuration-cache
else
./gradlew -p moshi-ir/moshi-gradle-plugin publishToMavenLocal -x dokkaHtml
./gradlew publishToMavenLocal -x dokkaHtml
./gradlew -p moshi-ir/moshi-gradle-plugin publishToMavenLocal
./gradlew publishToMavenLocal
fi
3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ includeBuild("moshi-ir/moshi-gradle-plugin") {
substitute(module("dev.zacsweers.moshix:moshi-gradle-plugin")).using(project(":"))
}
}

// https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:type-safe-project-accessors
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

0 comments on commit 5919286

Please sign in to comment.