From 16aa23182656c7082297270361475648e003b28e Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 6 Nov 2024 10:09:23 +0800 Subject: [PATCH] Configure the Dokka Gradle plugin, its tasks, and the GitHub Actions workflow, with code copied and adapted from "exposed-adt-mapping" A source commit: https://github.com/huanshankeji/exposed-adt-mapping/commit/18800b706e5d5bacd23ca9e20d8389bbef7d2a02 --- .github/workflows/dokka-gh-pages.yml | 61 ++++++++++++++++++++++++++++ build.gradle.kts | 8 ++++ buildSrc/build.gradle.kts | 1 + gradle.properties | 2 + lib/build.gradle.kts | 12 +++++- settings.gradle.kts | 8 ++++ 6 files changed, 91 insertions(+), 1 deletion(-) 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..53c853c --- /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: [ "plugins-release" ] + pull_request: + branches: [ "plugins-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..7b5b7b8 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-vertx-sql-client-postgresql")) +} 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 baa06d7..2a61c1c 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,6 +1,7 @@ plugins { conventions id("com.huanshankeji.benchmark.kotlinx-benchmark-jvm-conventions") + id("org.jetbrains.dokka") } dependencies { @@ -40,4 +41,13 @@ afterEvaluate { } "benchmarksImplementation"(commonDependencies.slf4j.simple()) } -} \ No newline at end of file +} + +dokka { + dokkaSourceSets.all { + sourceLink { + remoteUrl("https://github.com/huanshankeji/exposed-vertx-sql-client/tree/v${version}/lib") + remoteLineSuffix.set("#L") + } + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index f25580d..75fcf49 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,11 @@ rootProject.name = "exposed-vertx-sql-client" include("lib") project(":lib").name = rootProject.name + "-postgresql" + +// for Dokka +@Suppress("UnstableApiUsage") +dependencyResolutionManagement { + repositories { + mavenCentral() + } +}