Skip to content

Commit

Permalink
Migration to Dokka V2
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Dec 17, 2024
1 parent 0a0c176 commit 24966b4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ List of plugins currently available in the repository.

This plugin applies `no.nordicsemi.android.plugin.application` and adds Compose and Material3 dependency.

Since version 2.1 [`enableStrongSkippingMode`](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compiler.html#enablestrongskippingmode) is
[enabled](https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/6ee70d9f2fb2c2c8474067845eac05308740afa8/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/AndroidCompose.kt#L66).

3. [no.nordicsemi.android.plugin.library](plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt)

This plugin does the following:
Expand All @@ -42,9 +39,6 @@ List of plugins currently available in the repository.

This plugin applies `no.nordicsemi.android.plugin.library` and adds Compose and Material3 dependency.

Since version 2.1 [`enableStrongSkippingMode`](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compiler.html#enablestrongskippingmode) is
[enabled](https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/6ee70d9f2fb2c2c8474067845eac05308740afa8/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/AndroidCompose.kt#L66).

5. [no.nordicsemi.android.plugin.kotlin](plugins/src/main/kotlin/AndroidNexusRepositoryPlugin.kt)

This plugin applies `org.jetbrains.kotlin.android` and configures Kotlin compiler.
Expand All @@ -67,6 +61,14 @@ List of plugins currently available in the repository.

Creates `publish` and `releaseStagingRepositories` tasks using `maven-publish`.

Since 2.6 Dokka V2 is enabled.

Add
```
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
```
to _gradle.properties_ file.

### JVM plugins

1. [no.nordicsemi.jvm.plugin.kotlin](plugins/src/main/kotlin/JvmKotlinConventionPlugin.kt) (since 2.1)
Expand All @@ -83,6 +85,14 @@ and are available by their ids and version number.
> [!Note]
> Version 2.1 altered ids of the plugins by replacing `gradle` with `plugin`.
Since 2.6 Dokka V2 is enabled.

Add
```
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
```
to _gradle.properties_ file.

## Version catalog

![Maven Central Version](https://img.shields.io/maven-central/v/no.nordicsemi.android.gradle/version-catalog)
Expand Down
26 changes: 12 additions & 14 deletions plugins/src/main/kotlin/AndroidNexusRepositoryPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.Kapt
import org.jetbrains.dokka.gradle.DokkaExtension

class AndroidNexusRepositoryPlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target) {
pluginManager.apply {
with(pluginManager) {
apply("com.android.library")
apply("maven-publish")
apply("signing")
Expand All @@ -65,6 +63,7 @@ class AndroidNexusRepositoryPlugin : Plugin<Project> {
val nexusPluginExt = extensions.create("nordicNexusPublishing", NexusRepositoryPluginExt::class.java)
val library = extensions.getByType<LibraryExtension>()
val signing = extensions.getByType<SigningExtension>()
val dokka = extensions.getByType<DokkaExtension>()

// The signing configuration will be user by signing plugin.
extra.set("signing.keyId", System.getenv("GPG_SIGNING_KEY"))
Expand All @@ -82,18 +81,17 @@ class AndroidNexusRepositoryPlugin : Plugin<Project> {
}

// Instead, configure Dokka to generate HTML docs.
tasks.withType<DokkaTask>().configureEach {
dependsOn(tasks.withType<Kapt>())
dokka.apply {
dokkaSourceSets.configureEach {
noAndroidSdkLink.set(false)
enableAndroidDocumentationLink.set(true)
}
dokkaPublications.named("html") {
tasks.register<Jar>("dokkaHtmlJar").configure {
dependsOn(tasks.named("dokkaGenerate"))
from(outputDirectory)
archiveClassifier.set("html-docs")
}
}
}

tasks.register<Jar>("dokkaHtmlJar").configure {
val dokkaHtml = tasks.named("dokkaHtml", DokkaTask::class.java)
dependsOn(dokkaHtml)
from(dokkaHtml.flatMap { it.outputDirectory })
archiveClassifier.set("html-docs")
}

afterEvaluate {
Expand Down
28 changes: 12 additions & 16 deletions plugins/src/main/kotlin/JvmNexusRepositoryPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.Kapt
import org.jetbrains.dokka.gradle.DokkaExtension

class JvmNexusRepositoryPlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target) {
pluginManager.apply {
with(pluginManager) {
apply("org.jetbrains.kotlin.jvm")
apply("maven-publish")
apply("signing")
Expand All @@ -65,6 +63,7 @@ class JvmNexusRepositoryPlugin : Plugin<Project> {
val nexusPluginExt = extensions.create("nordicNexusPublishing", NexusRepositoryPluginExt::class.java)
val library = extensions.getByType<JavaPluginExtension>()
val signing = extensions.getByType<SigningExtension>()
val dokka = extensions.getByType<DokkaExtension>()

// The signing configuration will be user by signing plugin.
extra.set("signing.keyId", System.getenv("GPG_SIGNING_KEY"))
Expand All @@ -78,20 +77,17 @@ class JvmNexusRepositoryPlugin : Plugin<Project> {
// library.withJavadocJar()

// Instead, configure Dokka to generate HTML docs.
tasks.withType<DokkaTask>().configureEach {
dependsOn(tasks.withType<Kapt>())
dokka.apply {
dokkaSourceSets.configureEach {
noAndroidSdkLink.set(false)
enableAndroidDocumentationLink.set(true)
}
dokkaPublications.named("html") {
tasks.register<Jar>("dokkaHtmlJar").configure {
dependsOn(tasks.named("dokkaGenerate"))
from(outputDirectory)
archiveClassifier.set("javadoc")
}
}
}

tasks.register<Jar>("dokkaHtmlJar").configure {
val dokkaHtml = tasks.named("dokkaHtml", DokkaTask::class.java)
dependsOn(dokkaHtml)
from(dokkaHtml.flatMap { it.outputDirectory })
// Maven Central requires JVM libraries to have [module]-[version]-javadoc.jar file.
// Let's put Dokka HTML docs into the javadoc file.
archiveClassifier.set("javadoc")
}

afterEvaluate {
Expand Down

0 comments on commit 24966b4

Please sign in to comment.