Skip to content

[WIP] Publish SwiftJava libraries to Maven Central - #975

Draft
ktoso wants to merge 1 commit into
mainfrom
ktoso/maven-publishing
Draft

ktoso wants to merge 1 commit into
mainfrom
ktoso/maven-publishing

Conversation

@ktoso

@ktoso ktoso commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Good news! We're finally going to be publishing Java library releases to Maven Central!

This prepares for publishing all the java artifacts of SwiftJava to Maven Central, under the org.swift.swiftjava group.

The intent is to both publish:

  • snapshots - on every push to main,
  • tagged releases - which are 1:1 tracking whenever we tag a Swift release.

This is only dry running for now. We want to make sure we have the right publishing steps in place, also for the binary parts of the release including swiftkit-native which needs to be built for different platforms: osx-aarch_64, ubuntu24.04-swift_6.3-x86_64, etc.

🚧 🚧 Work in progress while we verify all the build steps and keys / signing etc 🚧 🚧

@ktoso ktoso changed the title Publish SwiftJava libraries to Maven Central [WIP] Publish SwiftJava libraries to Maven Central Nov 27, 2026
@ktoso
ktoso force-pushed the ktoso/maven-publishing branch 10 times, most recently from c0d82c7 to f4a50b1 Compare November 27, 2026 06:21
@ktoso
ktoso marked this pull request as draft November 27, 2026 06:28
Publish `swiftkit-core`, `swiftkit-ffm` and `swiftkit-native` under the
`org.swift.swiftjava` group with Gradle's `maven-publish` and `signing`
plugins, like ServiceTalk does, without a publishing plugin dependency:

- `.github/workflows/publish.yml`: a push to `main` publishes a `-SNAPSHOT`
  to the Central Portal snapshots repository, a pushed `N.N.N` tag publishes
  that release to Maven Central. The full test suite (`pull_request.yml`,
  now also a reusable workflow) has to pass first. The native libraries are
  then built on every platform, and one job signs and uploads everything,
  after the Gradle wrapper jar it runs with the secrets was checked against
  the checksum Gradle publishes (by hand, the organization doesn't allow
  third-party actions). `gradle-wrapper.jar` is updated to the one of
  Gradle 9.4.0, the version in `gradle-wrapper.properties` (it was 9.1.0's).
- Releases are uploaded to the Central Portal's OSSRH Staging API and turned
  into a deployment with `publishing_type=automatic`, so Central publishes
  them once validated, without a manual step in the Portal.
  `.github/scripts/central-release.sh` polls the Portal until Central has
  validated the deployment and fails the run, with Central's errors, if
  Central rejects it.
- Until the repository variable `MAVEN_CENTRAL_PUBLISHING` is `true`, every
  run is a dry run: it publishes everything signed to `build/staging-deploy`
  and verifies every signature, but uploads nothing. Pull requests that
  change the publishing setup always dry-run, with a throwaway signing key
  when the real one isn't available.
- Credentials (`SONATYPE_USER`, `SONATYPE_TOKEN`) and the signing key
  (`ORG_GRADLE_PROJECT_SIGNINGKEY`, `ORG_GRADLE_PROJECT_SIGNINGPASSWORD`)
  come from GitHub secrets and are only passed to the publish step.
  Publishing to Maven Central without them fails before anything runs.
- The version is derived from git tags in the root `build.gradle.kts`: the
  tag when HEAD is at a release tag, otherwise the next patch `-SNAPSHOT`.
  The publish job marks the checkout as a safe git directory, since the
  container runs as another user than the checkout's owner.
  This replaces `resolveSwiftKitVersion()`.
- `swiftkit-native` ships `libSwiftJava` and `libSwiftRuntimeFunctions` as one
  classifier jar per platform (`osx-aarch_64`, `ubuntu24.04-swift_6.3-x86_64`,
  ...), with the libraries at the jar root, where
  `SwiftLibraries.loadResourceLibrary` looks for them.
- `build-logic.java-publishing-conventions` adds the POM metadata Maven
  Central requires, signing, and the `staging` and `sonatype` repositories.
- `swiftkit-ffm` exposes `swiftkit-core` as an `api` dependency (compile scope
  in the POM), since its public API extends core types such as `SwiftArena`.
- `PUBLISHING.md` documents the artifacts and how to depend on them,
  `RELEASING.md` the maintainer setup, enabling publishing and the release
  process. `README.md` shows how to pick the `swiftkit-native` classifier with
  the osdetector Gradle plugin.
@ktoso
ktoso force-pushed the ktoso/maven-publishing branch from efe8601 to ba1f26e Compare November 27, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant