Skip to content

feat(manager,zpm-maven-plugin): resolve zpm dependencies ahead of an offline install - #2612

Merged
jfallows merged 6 commits into
developfrom
claude/friendly-bohr-kfi9h0
Sep 25, 2026
Merged

jfallows merged 6 commits into
developfrom
claude/friendly-bohr-kfi9h0

Conversation

@jfallows

@jfallows jfallows commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

zpm install merges automatic (non-modular) jars into a delegate module and generates its module-info with jdeps. jdeps can only check that module strictly when the delegated jars' <optional> and provided dependencies are available. An offline install (--exclude-remote-repositories) only sees what was already copied into its local repository. Maven never resolves optional or provided dependencies transitively, so that tree was always incomplete:

  • Aborted on the first missing POM. zpm's optional tree followed provided edges out of named modules (e.g. binding-http → binding-http.spec) and aborted on the first missing POM (resolved 0 optional dependencies).
  • Silent fallback. jdeps then fell back to --ignore-missing-deps, so the strict check quietly stopped checking.
  • Stock Maven goals don't fill the gap. Measured: dependency:go-offline follows optionals but not provided, and aborts on unresolvable classifiers. dependency:get only takes root-level optionals. go-offline-maven-plugin takes neither.

manager (zpm)

  • Optional tree rooted at the delegated artifacts. It's pinned to the main resolution's versions, so provided/optional edges out of named modules are never followed. Group ids aren't special-cased.
  • Missing/invalid descriptors tolerated in the optional tree (SimpleArtifactDescriptorPolicy(true, true)), so one missing POM no longer drops the whole tree.
  • New zpm resolve. It runs the same resolution and module classification as install, using a local Maven repository as its cache (--local-repository, reused across runs). It then exports every file it resolved, including jars, POMs, parent POMs and imported BOMs, into --repository-directory. That directory is a self-contained repository for a later offline install.
  • Export survives concurrent resolution. maven-resolver's collector resolves descriptors on a thread pool (aether.dependencyCollector.bf.threads), so artifactResolved events arrive concurrently. The paths to export are recorded in a concurrent set. With the unsynchronized set, an export could silently miss files. One CI run exported a repository without javaee-api's parent POMs, and the offline install --strict then collected no optional dependencies.
  • New zpm install --strict. It fails with the unresolved references instead of falling back. Default behaviour is unchanged.
  • Cache layout. zpm's cache now uses the simple local repository layout, so artifacts are reused regardless of which repository id originally provided them.
  • Refactor. The shared configuration, repository and classification steps moved from ZpmInstall into ZpmDependencyCommand.

build/zpm-maven-plugin (new)

  • Goal resolve, default phase prepare-package.
    • Renders a zpm.json.template with ${KEY} properties.
    • Fails if any template dependency isn't among the project's resolved dependencies. That keeps the project's declared dependencies, and therefore reactor ordering, in step with the template.
    • Runs zpm resolve into ${project.build.directory}/zpm/repository, and honours -o.
    • Exports the manager jar into the same repository, so the image's zpmw can bootstrap from it.
  • Isolated class loader. zpm is built on Maven Resolver 2, while Maven 3.9 exposes Resolver 1.9 to plugin realms. So the plugin runs the self-contained manager jar from its own class loader, and depends on it without transitive dependencies.

cloud/docker-image

  • Assembly. It binds zpm-maven-plugin:resolve, and assembly.xml now copies only the resolved repository. The hand-maintained local-repository include list is gone.
  • --strict in both Dockerfiles. Both Dockerfile and alpine.Dockerfile now run zpmw install with --strict. zilla links no delegate module today, so this changes nothing yet. It enforces the invariant from now on: an image never ships a delegate module whose module-info was generated while ignoring unresolved references.
  • command dependency. It declares the command dependency, which the new check flagged: it was listed in zpm.json.template but only reachable at provided scope.

Tests

  • ZpmCacheOptionalTest. The optional tree follows optional and provided dependencies of delegated artifacts, not those of named modules. A missing optional POM gives a partial tree, and the test fails without the descriptor policy. The exported repository is self-contained.
  • ZpmCacheExportTest. It fires 16,000 artifactResolved events from 8 threads and checks that every file is exported. Before the fix, only 552–1,010 files were exported (three runs). Single-threaded, all were exported.
  • ZpmResolveTest. It exports main and optional dependencies, and re-exports from the local repository cache after the export and the remote are removed.
  • ZpmInstallStrictTest. --strict fails when the delegate references a class that isn't resolvable.
  • Plugin tests. ZpmTemplateTest, ResolveMojoTest (skip, undeclared dependency, argument construction including offline, manager jar export) and ZpmLauncherTest (isolation, failure cause propagation).

Verification

  • Local verify. ./mvnw clean install -pl manager,build/zpm-maven-plugin passes, coverage checks met, no checkstyle violations.
  • End to end, without Docker.
    • ./mvnw package -pl cloud/docker-image -Ddocker.skip resolved 428 dependencies and exported them.
    • java -Duser.home=<dir containing only the export as .m2/repository> -jar manager.jar install --debug --instrument --exclude-remote-repositories --strict resolved all 428 and linked the runtime image. These are the same flags as the updated Dockerfile.
  • Missing parent POM, reproduced. I deleted javaee-api's parent POMs from an otherwise complete export. The offline install --strict then failed with the message from that CI run: Failed to collect dependencies at commons-logging:commons-logging:jar:1.2 -> log4j:log4j:jar:1.2.17 -> org.apache.openejb:javaee-api:jar:5.0-2, followed by resolved 0 optional dependencies.
  • Docker images, built locally.
    • Dockerfile: built via ./mvnw install -pl cloud/docker-image from the resolved repository only, and the image runs.
    • alpine.Dockerfile: built from the same assembled context: 428 dependencies resolved offline and linked with --strict; zilla version prints develop-SNAPSHOT.

🤖 Generated with Claude Code

https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg

…offline install

zpm install generates the delegate module's module-info with jdeps, which
can only run strictly when the delegated jars' optional and provided
dependencies are available. An offline install (--exclude-remote-repositories)
only sees what was already copied into its local repository, and Maven never
resolves optional or provided dependencies transitively, so the optional
tree was incomplete and jdeps silently fell back to --ignore-missing-deps.

- root the optional dependency tree at the delegated artifacts, pinned to
  the main resolution's versions, so provided dependencies of named modules
  are no longer followed
- tolerate missing or invalid descriptors in the optional tree instead of
  dropping it entirely
- add zpm resolve, which resolves main and optional dependencies into a
  local repository cache and exports every resolved file into a
  self-contained repository for a later offline install
- add zpm install --strict to fail instead of falling back when the
  delegate module references unresolved dependencies
- add build/zpm-maven-plugin with a resolve goal that renders
  zpm.json.template, checks its dependencies are declared by the project,
  and runs zpm resolve in an isolated class loader
- cloud/docker-image assembles the resolved repository instead of a
  hand-maintained list of local repository paths

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg
Exclude manager's transitive dependencies so the plugin realm carries
only the shaded manager jar that the launcher loads in isolation, and
regenerate the build aggregator NOTICE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg
zpm.json.template lists io.aklivity.zilla:command, which the command-*
modules only depend on at provided scope, so docker-image did not
resolve it. The zpm-maven-plugin resolve goal now reports such gaps.
Also add the generated zpm-maven-plugin NOTICE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg
Fail the image build when a delegate module would reference unresolved
dependencies instead of silently generating its module-info while
ignoring them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg
…itory

zpmw bootstraps by copying the manager jar from the local repository,
which the resolved repository did not contain because zpm itself is not
a zpm.json dependency, so the offline image build failed with
"Unable to access jarfile .zpm/wrapper/manager-develop-SNAPSHOT.jar".
Export the manager artifact the goal runs alongside the resolved
dependencies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg
maven-resolver's collector resolves artifact descriptors on a thread
pool, so artifactResolved events reach ZpmCache's listener
concurrently. The listener recorded the paths to export in a
LinkedHashSet, which silently drops entries under concurrent adds, so
zpm resolve could export an incomplete repository, e.g. without a
parent POM that an offline install then needs to collect the optional
tree.

Record resolved paths in a concurrent set. ZpmCacheExportTest fires
16000 artifactResolved events from 8 threads; before the fix only
552-1010 files were exported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg
@jfallows
jfallows merged commit 9010b1e into develop Sep 25, 2026
44 checks passed
jfallows added a commit that referenced this pull request Sep 26, 2026
…offline install (#2612)

* feat(manager,zpm-maven-plugin): resolve zpm dependencies ahead of an offline install

zpm install generates the delegate module's module-info with jdeps, which
can only run strictly when the delegated jars' optional and provided
dependencies are available. An offline install (--exclude-remote-repositories)
only sees what was already copied into its local repository, and Maven never
resolves optional or provided dependencies transitively, so the optional
tree was incomplete and jdeps silently fell back to --ignore-missing-deps.

- root the optional dependency tree at the delegated artifacts, pinned to
  the main resolution's versions, so provided dependencies of named modules
  are no longer followed
- tolerate missing or invalid descriptors in the optional tree instead of
  dropping it entirely
- add zpm resolve, which resolves main and optional dependencies into a
  local repository cache and exports every resolved file into a
  self-contained repository for a later offline install
- add zpm install --strict to fail instead of falling back when the
  delegate module references unresolved dependencies
- add build/zpm-maven-plugin with a resolve goal that renders
  zpm.json.template, checks its dependencies are declared by the project,
  and runs zpm resolve in an isolated class loader
- cloud/docker-image assembles the resolved repository instead of a
  hand-maintained list of local repository paths

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg

* build(zpm-maven-plugin): depend on the self-contained manager jar only

Exclude manager's transitive dependencies so the plugin realm carries
only the shaded manager jar that the launcher loads in isolation, and
regenerate the build aggregator NOTICE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg

* build(docker-image): declare command runtime dependency

zpm.json.template lists io.aklivity.zilla:command, which the command-*
modules only depend on at provided scope, so docker-image did not
resolve it. The zpm-maven-plugin resolve goal now reports such gaps.
Also add the generated zpm-maven-plugin NOTICE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg

* build(docker-image): install with zpm --strict

Fail the image build when a delegate module would reference unresolved
dependencies instead of silently generating its module-info while
ignoring them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg

* fix(zpm-maven-plugin): export the manager jar with the resolved repository

zpmw bootstraps by copying the manager jar from the local repository,
which the resolved repository did not contain because zpm itself is not
a zpm.json dependency, so the offline image build failed with
"Unable to access jarfile .zpm/wrapper/manager-develop-SNAPSHOT.jar".
Export the manager artifact the goal runs alongside the resolved
dependencies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg

* fix(manager): record resolved paths from concurrent resolver events

maven-resolver's collector resolves artifact descriptors on a thread
pool, so artifactResolved events reach ZpmCache's listener
concurrently. The listener recorded the paths to export in a
LinkedHashSet, which silently drops entries under concurrent adds, so
zpm resolve could export an incomplete repository, e.g. without a
parent POM that an offline install then needs to collect the optional
tree.

Record resolved paths in a concurrent set. ZpmCacheExportTest fires
16000 artifactResolved events from 8 threads; before the fix only
552-1010 files were exported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015AUJDQphhDuZTjetPaNsBg

---------

Co-authored-by: Claude <[email protected]>
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.

2 participants