Skip to content

fix(maven): use symlink instead of settings.xml for cache localRepository#2361

Merged
89luca89 merged 1 commit into
chainguard-dev:mainfrom
toabctl:fix/maven-cache-symlink
Feb 20, 2026
Merged

fix(maven): use symlink instead of settings.xml for cache localRepository#2361
89luca89 merged 1 commit into
chainguard-dev:mainfrom
toabctl:fix/maven-cache-symlink

Conversation

@toabctl

@toabctl toabctl commented Feb 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace settings.xml <localRepository> override with a symlink from ~/.m2/repository to /var/cache/melange/m2repository
  • Symlink is created at both /root/.m2/repository (qemu) and $HOME/.m2/repository (bubblewrap/docker)
  • Update docs to reflect the symlink approach

Problem

The pombump.yaml pipeline (added in #2304) unconditionally created /root/.m2/settings.xml with <localRepository>/var/cache/melange/m2repository</localRepository> whenever /var/cache/melange existed. This redirected where the Maven Resolver cached downloaded jars, but builds that hardcode ~/.m2/repository paths broke because jars were no longer at the expected location.

Specifically, Cassandra's build-resolver.xml expects jars at /root/.m2/repository/org/jacoco/org.jacoco.agent/0.8.8/org.jacoco.agent-0.8.8.jar and failed with BUILD FAILED: src '...' doesn't exist.

Fix

Use a symlink instead: ~/.m2/repository/var/cache/melange/m2repository. This way:

  • Maven's default local repository transparently points to the cache
  • Builds referencing ~/.m2/repository paths follow the symlink and find jars
  • Cache persistence still works (virtiofs writes go to host)

Testing

Verified locally with cassandra-5.0 build:

  • bubblewrap: BUILD SUCCESSFUL, symlink at $HOME/.m2/repository
  • qemu + virtiofs: BUILD SUCCESSFUL, symlink at /root/.m2/repository, 139MB cache persisted to host

…tory

The previous approach created a settings.xml with <localRepository>
pointing to /var/cache/melange/m2repository. This broke builds that
hardcode ~/.m2/repository paths (e.g. Cassandra's build-resolver.xml
expects jacoco jars at /root/.m2/repository/...).

Replace the settings.xml <localRepository> override with a symlink
from ~/.m2/repository to /var/cache/melange/m2repository. This way
Maven's default local repository transparently points to the cache
while builds referencing ~/.m2/repository still work.

The symlink is created at both /root/.m2/repository (qemu runner)
and $HOME/.m2/repository (bubblewrap/docker) to cover all runners.

Fixes cassandra-5.0 build failure (BUILD FAILED: src
'/root/.m2/repository/org/jacoco/org.jacoco.agent/0.8.8/
org.jacoco.agent-0.8.8.jar' doesn't exist).
@toabctl toabctl marked this pull request as ready for review February 20, 2026 16:00
@89luca89 89luca89 merged commit c8f86ae into chainguard-dev:main Feb 20, 2026
62 of 63 checks passed
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