From 4bf7115c6a82bed3d350d164d230685dec0b4c12 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Tue, 5 Nov 2024 18:57:27 +0800 Subject: [PATCH] Configure the Dokka Gradle plugin, its tasks, and the GitHub Actions workflow, with code copied and adapted from "kotlin-common" A source commit: https://github.com/huanshankeji/gradle-common/commit/d0c81059c453e854043475d9e7f077826ad84c8a The `dokkaGenerate` task fails with an error, which may be due to a bug from Dokka. This is similar to the problem in "gradle-common" so see https://github.com/huanshankeji/gradle-common/commit/d0c81059c453e854043475d9e7f077826ad84c8a for more details on this. --- .github/workflows/dokka-gh-pages.yml | 61 ++++++++++++++++++++++++++++ build.gradle.kts | 8 ++++ buildSrc/build.gradle.kts | 1 + gradle.properties | 2 + lib/build.gradle.kts | 10 +++++ 5 files changed, 82 insertions(+) create mode 100644 .github/workflows/dokka-gh-pages.yml create mode 100644 gradle.properties diff --git a/.github/workflows/dokka-gh-pages.yml b/.github/workflows/dokka-gh-pages.yml new file mode 100644 index 0000000..2781a64 --- /dev/null +++ b/.github/workflows/dokka-gh-pages.yml @@ -0,0 +1,61 @@ +name: Deploy the API documentation to GitHub Pages with Dokka + +on: + push: + branches: [ "release" ] + pull_request: + branches: [ "release" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + 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 + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: "8" + distribution: "temurin" + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build the distribution with Gradle Wrapper + run: ./gradlew :dokkaGeneratePublicationHtml + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: build/dokka/html/ + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/build.gradle.kts b/build.gradle.kts index 1241019..c5588d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,11 @@ tasks.wrapper { distributionType = Wrapper.DistributionType.ALL } + +plugins { + id("org.jetbrains.dokka") +} + +dependencies { + dokka(project(":exposed-adt-mapping")) +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index bf8774c..6a6f9e2 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -19,4 +19,5 @@ dependencies { implementation(kotlin("gradle-plugin", "2.0.10")) implementation("com.huanshankeji:common-gradle-dependencies:0.8.0-20241016") // don't use a snapshot version in a main branch implementation("com.huanshankeji.team:gradle-plugins:0.6.0") // don't use a snapshot version in a main branch + implementation("org.jetbrains.dokka:dokka-gradle-plugin:2.0.0-Beta") } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..4a50b9e --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +# for Dokka +org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index a4f2481..54f9243 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,5 +1,6 @@ plugins { conventions + id("org.jetbrains.dokka") } dependencies { @@ -8,3 +9,12 @@ dependencies { implementation(commonDependencies.kotlinCommon.reflect()) implementation(commonDependencies.kotlinCommon.core()) } + +dokka { + dokkaSourceSets.all { + sourceLink { + remoteUrl("https://github.com/huanshankeji/exposed-adt-mapping/tree/v${version}/lib") + remoteLineSuffix.set("#L") + } + } +}