From 72bdb1f4893b2701288c765deae496f471e848e3 Mon Sep 17 00:00:00 2001 From: Martin Gilbey Date: Wed, 19 Feb 2025 14:57:04 +0000 Subject: [PATCH] fix: Publish platform maven artifact Publish a maven artifact for the java platform gradle module that is used to version dependencies across other modules. Without this being published, users attempting to resolve the shared or server modules in gradle from the github package registry will receive an error because the "kotlin-language-server:platform" dependency referenced in the shared and server module POM's cannot be found. --- .github/workflows/deploy.yml | 2 +- ...e-server.publishing-conventions.gradle.kts | 17 +--------------- ...blishing-repository-conventions.gradle.kts | 20 +++++++++++++++++++ platform/build.gradle.kts | 13 +++++++++++- 4 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 buildSrc/src/main/kotlin/kotlin-language-server.publishing-repository-conventions.gradle.kts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 75630c05f..c3433ff42 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -41,7 +41,7 @@ jobs: tag="${{ steps.tag.outputs.tag }}" gh release upload "$tag" server/build/distributions/* - name: Deploy Maven artifacts to GitHub Packages - run: ./gradlew :shared:publish :server:publish + run: ./gradlew :shared:publish :server:publish :platform:publish env: GPR_USERNAME: ${{ github.actor }} GPR_PASSWORD: ${{ secrets.GITHUB_TOKEN }} diff --git a/buildSrc/src/main/kotlin/kotlin-language-server.publishing-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-language-server.publishing-conventions.gradle.kts index 74a214866..a3c23ec36 100644 --- a/buildSrc/src/main/kotlin/kotlin-language-server.publishing-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-language-server.publishing-conventions.gradle.kts @@ -1,23 +1,8 @@ plugins { - `maven-publish` -} - -repositories { - mavenCentral() + id("kotlin-language-server.publishing-repository-conventions") } publishing { - repositories { - maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/fwcd/kotlin-language-server") - credentials { - username = project.findProperty("gpr.user") as String? ?: System.getenv("GPR_USERNAME") - password = project.findProperty("gpr.key") as String? ?: System.getenv("GPR_PASSWORD") - } - } - } - publications { register("gpr", MavenPublication::class) { from(components["java"]) diff --git a/buildSrc/src/main/kotlin/kotlin-language-server.publishing-repository-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-language-server.publishing-repository-conventions.gradle.kts new file mode 100644 index 000000000..1f3633a92 --- /dev/null +++ b/buildSrc/src/main/kotlin/kotlin-language-server.publishing-repository-conventions.gradle.kts @@ -0,0 +1,20 @@ +plugins { + `maven-publish` +} + +repositories { + mavenCentral() +} + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/fwcd/kotlin-language-server") + credentials { + username = project.findProperty("gpr.user") as String? ?: System.getenv("GPR_USERNAME") + password = project.findProperty("gpr.key") as String? ?: System.getenv("GPR_PASSWORD") + } + } + } +} diff --git a/platform/build.gradle.kts b/platform/build.gradle.kts index 8d8a0a078..b7261a8de 100644 --- a/platform/build.gradle.kts +++ b/platform/build.gradle.kts @@ -1,4 +1,7 @@ -plugins { id("java-platform") } +plugins { + id("java-platform") + id("kotlin-language-server.publishing-repository-conventions") +} javaPlatform { allowDependencies() } @@ -29,3 +32,11 @@ dependencies { api(libs.org.xerial.sqlite.jdbc) } } + +publishing { + publications { + register("gpr", MavenPublication::class) { + from(components["javaPlatform"]) + } + } +}