fix(manifest): keep the Maven extension build out of the developer's home directory - #1461
Open
John-David Dalton (jdalton) wants to merge 1 commit into
Open
fix(manifest): keep the Maven extension build out of the developer's home directory#1461John-David Dalton (jdalton) wants to merge 1 commit into
John-David Dalton (jdalton) wants to merge 1 commit into
Conversation
…home directory The maven-extension jar build invoked the bundled Maven wrapper with no repository override, so every run downloaded the plugin and dependency closure into the developer's ~/.m2/repository and the Maven distribution into ~/.m2/wrapper/dists. Point both at a stable directory under the OS temp dir instead. The path is stable rather than per-run so the closure stays cached between builds; SOCKET_CLI_MAVEN_HOME overrides it for a genuinely cold build.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2e7512b. Configure here.
| ( | ||
| cd "$here" | ||
| MAVEN_USER_HOME="$maven_home" ./mvnw -q --batch-mode \ | ||
| -Dmaven.repo.local="$maven_home/repository" package |
There was a problem hiding this comment.
Relative cache path cwd mismatch
Medium Severity
When SOCKET_CLI_MAVEN_HOME or TMPDIR is a relative path, mkdir -p uses the caller’s working directory, but MAVEN_USER_HOME and -Dmaven.repo.local are applied after cd into the extension directory, so Maven and the wrapper write to a different tree than the one created upfront.
Reviewed by Cursor Bugbot for commit 2e7512b. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Building the Coana Maven extension writes into your own home directory.
build-jar.shcalls the bundled Maven wrapper with no repository override, so every run drops the plugin and dependency closure into~/.m2/repositoryand the wrapper's own downloaded Maven distribution into~/.m2/wrapper/dists. Run the script once and your personal Maven cache now holds artifacts you never asked for.The bigger problem is reproducibility, not tidiness. When a build reads and writes a cache that lives in your home directory, it can quietly succeed because of something an unrelated project downloaded months ago. The same build on a clean machine, or in CI, does not have that cache and can fail for reasons nobody can reproduce locally.
This change points the build at a directory under the OS temp dir instead, so it stops touching your home Maven tree and always resolves from a cache it owns.
The change — two overrides, because Maven splits the work between two programs
Setting one override alone leaves the other half still writing to the home directory:
-Dmaven.repo.localmvnbinaryMAVEN_USER_HOMEmvnwshell script, notmvnBoth now point inside a single directory under the OS temp root, and the Maven invocation runs in a subshell so the environment change does not leak into the rest of the script.
Why a stable path and not a fresh one each run — a cold cache every time would make the build slow and network-dependent
A brand new temp directory per run is the most isolated option, but it throws away the cache every time. The extension build needs a full plugin closure, so every invocation would re-download it and the build would become slow and dependent on the network being up.
A stable path under the temp dir keeps the isolation while letting the cache stay warm between runs. Anyone who genuinely wants a cold build can set
SOCKET_CLI_MAVEN_HOMEto somewhere else.How this was verified — Maven's behaviour was measured before and after, not assumed
Maven's behaviour was checked directly before and after, by recording a timestamp and then listing files newer than it.
Confirming the leak is real, using a dependency version that was not already cached:
Confirming the overrides work:
-Dmaven.repo.localpointed at a temp directory, that directory received the full closure and the local repository under the home directory received zero new files.MAVEN_USER_HOMEon its own does not move the artifact repository. Themvnbinary ignores it, and the directory is never even created. It only moves the wrapper distribution, which is why the fix sets both.MAVEN_USER_HOMEpointed at a temp directory, the requested Maven distribution was unpacked there and the wrapper directory under the home directory was unchanged.Confirming the patched script end to end:
build-jar.shran to completion and producedcoana-maven-extension.jar.Scope — only the extension build; the JVM test fixtures are a separate PR
Only
build-jar.shchanges. The Maven, Gradle and sbt compatibility fixtures underscripts/test/have the same class of problem and are being handled separately; they are untouched here.Note
Low Risk
Build-script-only change for the CLI Maven extension jar; no runtime manifest or auth paths are touched.
Overview
build-jar.shno longer lets the bundledmvnwpopulate the developer’s~/.m2. The Maven invocation runs in a subshell withMAVEN_USER_HOMEand-Dmaven.repo.localboth aimed at a stable directory under the OS temp root (defaultsocket-cli-maven-home), so wrapper distributions and dependency/plugin caches stay out of the home Maven tree while remaining warm across runs.SOCKET_CLI_MAVEN_HOMEoverrides that base path when someone wants a cold or custom cache location. The jar copy step and output path are unchanged.Reviewed by Cursor Bugbot for commit 2e7512b. Configure here.