Skip to content

Commit

Permalink
replace the Dokka Gradle plugin with Dokkatoo
Browse files Browse the repository at this point in the history
  • Loading branch information
RBusarow committed Nov 20, 2023
1 parent 18ae172 commit 4e79743
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions build-logic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
compileOnly(gradleApi())
implementation libs.ktlintRaw
implementation libs.kgx
implementation libs.dokkatoo.plugin
implementation libs.kotlinpoet
implementation libs.kotlin.dokka
implementation libs.kotlin.gradlePlugin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.squareup.anvil

import com.rickbusarow.kgx.libsCatalog
import com.rickbusarow.kgx.version
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishBasePlugin
import com.vanniktech.maven.publish.Platform
import dev.adamko.dokkatoo.DokkatooExtension
import dev.adamko.dokkatoo.DokkatooPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
Expand All @@ -14,9 +19,9 @@ import javax.inject.Inject

open class PublishConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
target.plugins.apply(MavenPublishBasePlugin::class.java)

target.plugins.apply("com.vanniktech.maven.publish.base")
target.plugins.apply("org.jetbrains.dokka")
target.applyDokkatoo()

target.extensions.create("publish", PublishExtension::class.java)

Expand All @@ -30,7 +35,6 @@ open class PublishConventionPlugin : Plugin<Project> {
mavenPublishing.signAllPublications()

target.plugins.withId("org.jetbrains.kotlin.jvm") {

when {
target.plugins.hasPlugin(pluginPublishId) -> {
// Gradle's 'plugin-publish' plugin creates its own publication. We only apply this plugin
Expand All @@ -41,13 +45,23 @@ open class PublishConventionPlugin : Plugin<Project> {
configurePublication(
target,
mavenPublishing,
KotlinJvm(javadocJar = JavadocJar.Dokka("dokkaHtml"), sourcesJar = true),
KotlinJvm(
javadocJar = JavadocJar.Dokka("dokkatooGeneratePublicationHtml"),
sourcesJar = true,
),
)
}
}
}
}

private fun Project.applyDokkatoo() {
plugins.apply(DokkatooPlugin::class.java)
extensions.configure(DokkatooExtension::class.java) {
it.versions.jetbrainsDokka.set(libsCatalog.version("dokka"))
}
}

@Suppress("UnstableApiUsage")
private fun configurePublication(
target: Project,
Expand Down
5 changes: 0 additions & 5 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ dependencies {
testImplementation libs.truth
}

// Fixes:
// Reason: Task ':compiler:dokkaHtml' uses this output of task ':compiler:kaptKotlin'
// without declaring an explicit or implicit dependency.
tasks.named("dokkaHtml") { mustRunAfter("kaptKotlin") }

tasks.withType(KotlinCompile).configureEach {
compilerOptions {
// The flag is needed because we extend an interface that uses @JvmDefault and the Kotlin
Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ autoValue = "1.10.4"
buildconfig = "4.1.2"
dagger = "2.46.1"
dokka = "1.9.10"
dokkatoo = "2.0.0"
espresso = "3.5.1"
gradlePublish = "1.2.1"
kct = "0.3.1"
Expand Down Expand Up @@ -48,6 +49,7 @@ config-generateDaggerFactoriesWithAnvil = "true"
agp-application = { id = "com.android.application", version.ref = "agp" }
agp-library = { id = "com.android.library", version.ref = "agp" }
buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" }
dokkatoo = { id = "dev.adamko.dokkatoo", version.ref = "dokkatoo" }
gradlePublish = { id = "com.gradle.plugin-publish", version.ref = "gradlePublish" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
Expand Down Expand Up @@ -78,6 +80,8 @@ auto-value-processor = { module = "com.google.auto.value:auto-value", version.re
dagger2 = { module = "com.google.dagger:dagger", version.ref = "dagger" }
dagger2-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" }

dokkatoo-plugin = { module = "dev.adamko.dokkatoo:dokkatoo-plugin", version.ref = "dokkatoo" }

gradlePublishRaw = { module = "com.gradle.publish:plugin-publish-plugin", version.ref = "gradlePublish" }

inject = "javax.inject:javax.inject:1"
Expand Down

0 comments on commit 4e79743

Please sign in to comment.