Skip to content

Commit

Permalink
Integrate Dokka (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 authored May 6, 2024
1 parent ca2435f commit dd8531e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.register
Expand All @@ -21,6 +22,23 @@ class PillarboxAndroidLibraryPublishingPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
pluginManager.apply("com.android.library")
pluginManager.apply("org.gradle.maven-publish")
pluginManager.apply("org.jetbrains.dokka")

val dokkaHtmlJar = tasks.register<Jar>("dokkaHtmlJar") {
val dokkaHtmlTask = tasks.named("dokkaHtml")

dependsOn(dokkaHtmlTask)
from(dokkaHtmlTask.map { it.outputs })
archiveClassifier.set("html-docs")
}

val dokkaJavadocJar = tasks.register<Jar>("dokkaJavadocJar") {
val dokkaJavadocTask = tasks.named("dokkaJavadoc")

dependsOn(dokkaJavadocTask)
from(dokkaJavadocTask.map { it.outputs })
archiveClassifier.set("javadoc")
}

extensions.configure<LibraryExtension> {
defaultConfig {
Expand All @@ -31,14 +49,16 @@ class PillarboxAndroidLibraryPublishingPlugin : Plugin<Project> {
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

extensions.configure<PublishingExtension> {
publications {
register<MavenPublication>("gpr") {
artifact(dokkaHtmlJar)
artifact(dokkaJavadocJar)

afterEvaluate {
from(components["release"])
}
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugins {
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.detekt)
alias(libs.plugins.dependency.analysis.gradle.plugin)
alias(libs.plugins.dokka) apply false
alias(libs.plugins.kotlinx.kover)
}

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ android.useAndroidX=true
kotlin.code.style=official

org.gradle.caching=true
org.gradle.configuration-cache=true
# Disable configuration cache until Dokka supports it: https://github.com/Kotlin/dokka/issues/2231
org.gradle.configuration-cache=false
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ coil = "2.6.0"
comscore = "6.11.1"
dependency-analysis-gradle-plugin = "1.31.0"
detekt = "1.23.6"
dokka = "1.9.20"
guava = "32.1.3-android"
json = "20240303"
junit = "4.13.2"
Expand Down Expand Up @@ -139,6 +140,7 @@ android-application = { id = "com.android.application", version.ref = "android-g
android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }
dependency-analysis-gradle-plugin = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependency-analysis-gradle-plugin" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
Expand Down

0 comments on commit dd8531e

Please sign in to comment.