Maven publishing
Audience: contributors and maintainers. How Book’s modules are published to Maven repositories, what artifacts to expect, and how to publish locally.
Book publishes its library modules with the
vanniktech Maven Publish plugin
(com.vanniktech.maven.publish 0.37.0), configured once at the root project. The
published version comes from shipkit-auto-version: the git tag on
the build commit. No module carries its own publishing configuration.
Quick start: publish to your local Maven repository
./gradlew publishToMavenLocal
Artifacts land in ~/.m2/repository/us/nineworlds/book/ at the resolved version
(run ./gradlew :jvm:cli:properties -q | grep "^version" to check). Local
publishing is unsigned. GPG signing activates only when CI-provided key material is
present (see Signing).
What gets published
Eight modules are published; three are excluded.
Published modules
| Artifact | Module | Notes |
|---|---|---|
|
|
KMP |
|
|
KMP |
|
|
KMP |
|
|
KMP |
|
|
KMP |
|
|
KMP |
|
|
JVM |
|
|
JVM. Publishes the shadow fat jar as the main artifact |
Naming rule: book-<dashed-module-path>, e.g. :core:domain โ book-core-domain.
Excluded modules
| Module | Reason |
|---|---|
|
Docs pipeline, not a library |
|
Deferred; needs a separate ADR |
|
Test harness, not consumable |
Artifact shape
-
KMP modules publish a root artifact (
book-core-domain) with Gradle Module Metadata (.module) plus one artifact per platform target:book-core-domain-jvm,book-core-domain-iosarm64,book-core-domain-iossimulatorarm64. Gradle consumers add only the root coordinate; Gradle picks the platform variant. -
JVM modules publish a plain jar.
-
All modules get
-sources.jarand-javadoc.jarper vanniktech defaults, plus a.pomand.module.
Where the configuration lives
Everything is centralized in the root build.gradle.kts:
-
The plugin is declared
apply falsein the root plugins block. Opt-in modules add one line to their ownpluginsblock:
`kotlin alias(libs.plugins.vanniktech.publish) `
-
The root
subprojects {}block then configures, viaplugins.withId("com.vanniktech.maven.publish"): -
group = "us.nineworlds.book"andcoordinates()(artifactId from the module path, version from shipkit-auto-version) -
configureBasedOnAppliedPlugins(): artifact wiring derived from each module’s plugins (KMP โ Gradle Module Metadata; JVM โ jar; Kotlin โ sources and javadoc jars) -
POM metadata: MIT license, project URL, SCM (
gitlab.com/kingargyle/book), inception year 2026, developers (David Carver, Ravi Bhojwani) -
A GitLab Maven registry repository (task creation only; see below)
-
Gated Maven Central publication and GPG signing (see below)
The plugin version is catalog-managed: vanniktech-publish in gradle/libs.versions.toml.
Excluding a module
An excluded module does not apply the plugin, so there is no extra list to maintain.
To publish a currently excluded module, add alias(libs.plugins.vanniktech.publish)
to its plugins block.
Target repositories
GitLab Maven package registry (always configured)
Each published module gets publish*PublicationToGitLabRepository tasks targeting
$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/maven, authenticated with the CI
Job-Token header (GitLab CI populates it; the defaults are inert locally). Locally
the repository exists but is not meant to be used.
How CI publishes (the tag pipeline)
CI publishing is wired in .gitlab-ci.yml. Pushing a release
tag (0.9.0 or v0.9.0, pre-releases like 0.10.0-beta.1 included) triggers a
pipeline with this stage order:
| Stage | Job | What it does |
|---|---|---|
|
|
|
|
|
|
|
|
Manual; see below |
|
|
Skipped on tags. The docs site tracks the default branch |
|
|
Asserts tag == version, uploads the CLI distribution, creates the GitLab release |
Notes:
-
The
releasejob first asserts the tag equals the derived version (./gradlew propertiescompared against$CI_COMMIT_TAG,vprefix stripped). If a tag ever disagrees with the build version, the release fails rather than publishing a mismatched artifact. -
The CLI distribution is built with
installDist, tarballed, and uploaded to the generic package registry, then linked in the release assets alongside the Maven package and the documentation site. -
The same regex gates all tag-only jobs:
^v?\.[0-9]\.(-[a-zA-Z0-9.])?$. -
Non-tag pipelines (MRs, default branch) never run
publishorrelease.
Maven Central publishing (manual CI job)
On a tag pipeline there is a manual publish-maven-central job. A maintainer starts
it to publish to Maven Central; it runs
./gradlew publishToMavenCentral -PpublishToMavenCentral=true. Two prerequisites:
-
Configure protected CI variables
mavenCentralUsername/mavenCentralPassword(Project Settings โ CI/CD โ Variables; mark them protected and masked). -
Enable
$CI_JOB_TOKENpackage uploads: Project Settings โ Packages โ allow publish via job token. The generic-package upload inreleaseneeds this too.
The job fails fast when credentials are missing; it never silently misconfigures.
Publications land in Central as pending (automaticRelease = false); a human
confirms the release in the Central Portal. OSSRH remains available through the
plugin’s SonatypeHost option. The final host choice is an open ADR (see Deferrals).
Signing
signAllPublications() is gated. It activates only when signing key material is
present (ORG_GRADLE_PROJECT_signingKey, or the vanniktech in-memory variants
signingInMemoryKey / signingInMemoryKeyPassword / signingInMemoryKeyId,
including their gradle-property forms). Local publishing stays unsigned. In CI,
providing the variables is enough; no build-script change.
Consuming the published artifacts
Artifacts reach two places: the GitLab Maven package registry (automatic, on every tag) and Maven Central (manual, when a maintainer runs that job). Consumers pick whichever they have access to.
From the GitLab Maven package registry
The registry URL is the same one CI publishes to:
https://gitlab.com/api/v4/projects/kingargyle%2Fbook/packages/maven
(kingargyle%2Fbook is the URL-encoded project path; %2F is the encoded slash.
You can also use the numeric project ID.)
Book is currently private; it is moving to a public project. Until then, reads need a credential. Three options:
-
Personal access token (read_api scope) for yourself, in
gradle.propertiesin your Gradle user home (~/.gradle/gradle.properties, not the project’s):
`properties bookGitLabToken=<your token> `
-
Project deploy token (read_package_registry scope) for a team or CI, using the token’s own username:
`properties bookGitLabUser=<deploy token username> bookGitLabToken=<deploy token> `
-
Group-level deploy token or CI job token for pipelines in other GitLab projects that consume Book. A job token works directly: inside another project’s CI job,
$CI_JOB_TOKENcan read packages of any project that grants it access.
Once the project is public, the token setup disappears: point Gradle at the URL
and resolve. The repository block below works unchanged either way; just remove
the credentials and authentication parts (or leave them, they are ignored for
anonymous access).
Wire it into the consumer’s settings.gradle.kts (or build.gradle.kts):
dependencyResolutionManagement {
repositories {
maven {
url = uri("https://gitlab.com/api/v4/projects/kingargyle%2Fbook/packages/maven")
name = "BookGitLab"
credentials(HttpHeaderCredentials::class) {
name = "Private-Token" // or "Deploy-Token"
value = providers.gradleProperty("bookGitLabToken").orElse("")
}
authentication {
create<HttpHeaderAuthentication>("header")
}
}
mavenCentral()
}
}
Header name varies by credential: Private-Token for a personal access token,
Deploy-Token for a deploy token, Job-Token for a CI job token. Deploy tokens
can also authenticate with basic auth using the token’s username; Gradle accepts
either form.
Then add the dependencies:
dependencies {
implementation("us.nineworlds.book:book-core-domain:0.9.0")
implementation("us.nineworlds.book:book-features-mcp:0.9.0")
}
KMP consumers get platform variants automatically through Gradle Module Metadata.
Complete Gradle consumer example
A minimal project layout:
my-consumer/
โโโ settings.gradle.kts
โโโ gradle.properties (only while Book is private: token lives in ~/.gradle/gradle.properties)
โโโ build.gradle.kts
settings.gradle.kts:
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
// Book artifacts: GitLab first, then Central
maven {
url = uri("https://gitlab.com/api/v4/projects/kingargyle%2Fbook/packages/maven")
name = "BookGitLab"
credentials(HttpHeaderCredentials::class) {
name = "Private-Token" // or Deploy-Token / Job-Token, see above
value = providers.gradleProperty("bookGitLabToken").orElse("")
}
authentication { create<HttpHeaderAuthentication>("header") }
}
mavenCentral()
}
}
rootProject.name = "my-consumer"
build.gradle.kts:
plugins {
kotlin("jvm") version "2.4.20"
}
dependencies {
implementation("us.nineworlds.book:book-core-domain:0.9.0")
implementation("us.nineworlds.book:book-features-mcp:0.9.0")
}
Then ./gradlew build resolves Book from the registry. Once Book is public, the
credentials and authentication blocks can be deleted and resolution stays
anonymous.
Complete Maven consumer example
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-consumer</artifactId>
<version>1.0.0</version>
<repositories>
<!-- Book artifacts. Server id `book-gitlab` must match the <server> below. -->
<repository>
<id>book-gitlab</id>
<url>https://gitlab.com/api/v4/projects/kingargyle%2Fbook/packages/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>us.nineworlds.book</groupId>
<artifactId>book-core-domain-jvm</artifactId>
<version>0.9.0</version>
</dependency>
</dependencies>
</project>
Credentials go in the consumer’s ~/.m2/settings.xml (never in the pom):
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0">
<servers>
<server>
<id>book-gitlab</id>
<!-- Personal access token: username is anything non-blank, password is the token -->
<username>book-consumer</username>
<password>${env.BOOK_GITLAB_TOKEN}</password>
</server>
</servers>
</settings>
Two Maven-specific notes:
-
Maven does not read Gradle Module Metadata. Depend on the platform artifact directly:
book-core-domain-jvmfor JVM consumers (or the iOS/native artifact you need), not the rootbook-core-domain. -
For CI job tokens, the username is
Job-Token’s companion: set `<username>to the literal stringgitlab-ci-tokenand<password>to$CI_JOB_TOKEN.
After the project goes public, the <server> entry can be dropped.
From Maven Central
Once a maintainer has run the manual publish-maven-central job and confirmed the
release in the Central Portal, artifacts resolve from Maven Central with no extra
repository configuration:
repositories {
mavenCentral()
}
dependencies {
implementation("us.nineworlds.book:book-core-domain:0.9.0")
}
Use the Central coordinates when you can: no tokens, no project access needed, and the same version numbering as the GitLab registry. GitLab-only versions exist when a tag was published before Central publishing started, or when Central publishing was skipped for that tag.
Which one to use
| Situation | Use |
|---|---|
Any version published to Central |
Maven Central, always |
A version only in the GitLab registry (pre-Central tags, skipped Central publish) |
GitLab registry |
Internal company projects before the public launch |
GitLab registry |
Consumers that already depend on |
Maven Central |
If you list both repositories (as the GitLab example above does), Gradle checks GitLab first, then Central. Order matters only for speed; coordinates are identical in both, so resolution is unambiguous.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
|
Signing key material is visible but invalid. Check the |
Version resolves to |
Expected. Shipkit derives from git tags, and no tag exists on your commit. See Versioning |
A module has no |
It has not opted in. Add the vanniktech plugin line, and confirm it is not in the excluded list |
A module was published that should be excluded |
Remove the |
|
|
|
The tag and the shipkit-derived version disagree: wrong commit tagged, or a re-pointed tag. Re-tag the correct commit; never re-point tags |
|
CI variables |
A tag push produced no |
The tag does not match the release regex (e.g. |
Release created but no CLI distribution link |
The |
Deferrals (future ADRs)
-
OSSRH vs Maven Central Portal: the plugin supports both; final host not chosen yet.
-
:jvm:extensionspublishing: excluded until it has its own ADR. -
:jvm:clidistribution: the fat jar is the Maven artifact; runnable distributions go through the GitLab generic package registry. -
The
book-jvm-clifat jar is ~106 MB. If Maven Central’s upload limits become a problem, revisit what:jvm:clipublishes.
Maintainer checklist for a release
-
Merge to the default branch; confirm
buildis green on the MR pipeline. -
Tag the release commit:
git tag 0.9.1 && git push origin 0.9.1. Tag the commit that has the version you want; shipkit derives everything from it. -
Watch the tag pipeline:
buildโpublishโrelease. -
Optional: run the manual
publish-maven-centraljob once the GitLab registry publication is verified. -
Confirm the release in the Maven Central Portal. Publications land as pending.
-
Verify the GitLab release page shows the CLI distribution and Maven package links.
Never re-point a tag. The tag is the version: shipkit-auto-version derives the
artifacts, the CLI banner, and the assertion from it.
Further reading
-
Versioning & release management: where the published version comes from
-
Building the Docs: the
:documentationmodule -
ADR:
prompts/plans/adr/ADR-20261111-shipkit-auto-version-maven-publishing.md -
CI publish/release pipeline:
prompts/plans/shipkit-versioning-publishing/spec-3-gitlab-ci-publish-release.md