From af86609ae6dc7ba0499a056a4aaa04e133f526a8 Mon Sep 17 00:00:00 2001 From: Ohad Shai Date: Fri, 1 Aug 2025 16:30:32 +0300 Subject: [PATCH 1/2] upgrade dokka to v2 --- build.gradle.kts | 35 +++++++++++++++++++++++++++-------- gradle.properties | 1 + 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a826a394..335d11c9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,8 @@ // File: build.gradle.kts import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL import org.gradle.jvm.tasks.Jar +import org.jetbrains.dokka.gradle.DokkaTask +import org.jetbrains.dokka.gradle.DokkaTaskPartial import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinVersion @@ -285,13 +287,7 @@ tasks { // Docs -tasks { - register("dokkaJar") { - from(dokkaHtml) - dependsOn(dokkaHtml) - archiveClassifier.set("javadoc") - } -} + // Tests @@ -357,7 +353,7 @@ publishing { url.set("https://github.com/oshai/kotlin-logging/tree/master") } } - artifact(tasks["dokkaJar"]) + } } @@ -385,4 +381,27 @@ tasks.withType().configureEach { val signingTasks = tasks.withType() mustRunAfter(signingTasks) } +tasks.withType().configureEach { + dokkaSourceSets.configureEach { + // We want to see all declarations, even if they are not explicitly documented. + reportUndocumented.set(true) + } +} + +val dokkaHtmlPublication by tasks.creating(DokkaTask::class) { + outputDirectory.set(buildDir.resolve("dokka/html")) +} + +val javadocJar by tasks.register("javadocJar") { + dependsOn(dokkaHtmlPublication) + from(dokkaHtmlPublication.outputDirectory) + archiveClassifier.set("javadoc") +} + +publishing { + publications.withType { + artifact(javadocJar) + } +} + //endregion diff --git a/gradle.properties b/gradle.properties index f030b8bc..5b42b9b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,3 +4,4 @@ org.gradle.jvmargs=-Xmx2048m # see https://kotlinlang.org/docs/whatsnew18.html#sourcedirectories kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.mpp.applyDefaultHierarchyTemplate=false +org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled From 06bf5e5b499a60112ce3e555a8493ff15a5cb59c Mon Sep 17 00:00:00 2001 From: Ohad Shai Date: Fri, 1 Aug 2025 21:53:19 +0300 Subject: [PATCH 2/2] fix dokka workflow --- .github/workflows/github-pages.yml | 50 ++++++++---------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index b3be779c..2798c227 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -1,5 +1,5 @@ -# Sample workflow for building and deploying a Jekyll site to GitHub Pages -name: Deploy to GitHub Pages +# Workflow for building and deploying Dokka documentation to GitHub Pages +name: Deploy Dokka Docs to GitHub Pages on: # Runs on pushes targeting the default branch @@ -16,60 +16,36 @@ permissions: id-token: write # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: group: "pages" cancel-in-progress: false -env: - JEKYLL_OUTPUT_DIR: ./dist - DOKKA_ARTIFACT_NAME: dokka-html - jobs: - api-docs: - name: Generate Dokka HTML docs + # Build and upload the Dokka documentation + build-and-upload: + name: Generate and Upload Dokka Docs runs-on: macos-latest # For Kotlin/Native steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v4 + - name: Configure JDK uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: 17 + - name: Generate Dokka HTML docs run: ./gradlew :dokkaHtml - - name: Upload Dokka output - uses: actions/upload-artifact@v4 - with: - name: ${{ env.DOKKA_ARTIFACT_NAME }} - path: build/dokka/html - if-no-files-found: error - # Build job - build: - name: Build Jekyll docs - runs-on: ubuntu-latest - needs: api-docs - steps: - # Workaround for https://github.com/actions/jekyll-build-pages/issues/101 - - name: Create output directory - run: mkdir ${{ env.JEKYLL_OUTPUT_DIR }} + - name: Setup Pages uses: actions/configure-pages@v5 - - name: Build with Jekyll - uses: actions/jekyll-build-pages@v1 - with: - source: ./ - destination: ${{ env.JEKYLL_OUTPUT_DIR }} - - name: Download Dokka artifact - uses: actions/download-artifact@v4 - with: - name: ${{ env.DOKKA_ARTIFACT_NAME }} - path: ${{ env.JEKYLL_OUTPUT_DIR }}/api + - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: ${{ env.JEKYLL_OUTPUT_DIR }} + # Upload the generated Dokka HTML directory + path: build/dokka/html # Deployment job deploy: @@ -78,7 +54,7 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest - needs: build + needs: build-and-upload # Wait for the build job to finish steps: - name: Deploy to GitHub Pages id: deployment