Skip to content

feat(manifest): build every POM a scan uploads with --dynamic-sbom-inference - #1660

Merged
Jeppe Fredsgaard Blaabjerg (jfblaa) merged 3 commits into
v1.xfrom
jfblaa/dsi-maven-pom-pattern
Oct 27, 2026
Merged

Jeppe Fredsgaard Blaabjerg (jfblaa) merged 3 commits into
v1.xfrom
jfblaa/dsi-maven-pom-pattern

Conversation

@jfblaa

@jfblaa Jeppe Fredsgaard Blaabjerg (jfblaa) commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

LLM Description written by Claude Code:claude-opus-5-5

--dynamic-sbom-inference only discovered Maven builds through files named exactly pom.xml. A scan uploads more POMs than that: depscan's supported-file pattern for POMs is {*-*.,}pom{.xml,}, matched case-insensitively. Those other POMs were uploaded without a facts build. Discovery now follows the upload rules.

  • Same POMs as the upload: the same pattern, case-insensitive, honouring .gitignore and now also projectIgnorePaths in socket.yml, as the upload does. A POM a scan would not upload is not built either.
  • One build per POM: a directory can hold several builds. A POM other than pom.xml runs with mvn --file <pom>, and its facts file is named after it (<pom>.socket.facts.json). Coverage by a parent build is judged per file, so a covered POM doesn't hide an uncovered sibling.
  • --exclude-paths unchanged: it stays case-sensitive; only the POM name match ignores case.
  • Setup wizard (socket manifest setup --recursive): asks once per directory holding several POMs. It no longer disables a whole directory when --exclude-paths matches only one of its POMs, and warns instead.

Things to be aware of:

  • Published artifact POMs (<artifactId>-<version>.pom) are now built too, because depscan accepts them. An in-tree Maven repository (e.g. a project-local .m2/repository) is skipped when gitignored or listed in projectIgnorePaths; otherwise use --exclude-paths. A POM that fails to build still stops the remaining Maven builds in the run, as before.
  • The pattern is copied from the API's supported files rather than fetched, since socket manifest runs without the API.

Tested:

  • New unit tests for discovery (names, case, .gitignore, projectIgnorePaths, --exclude-paths), per-POM runs and coverage, and the wizard.
  • A real run on a project with pom.xml, app-dev.pom.xml, a bare pom and a gitignored .m2 artifact POM produced three facts files, each from its own POM.

🤖 Generated with Claude Code


Note

Medium Risk
Changes Maven discovery and how many mvn invocations run (including vendored/artifact POMs), which can increase build time or fail the whole Maven walk on a bad POM; behavior is well-covered by tests but may surprise repos that previously only built pom.xml.

Overview
--dynamic-sbom-inference now treats Maven like a scan upload: discovery uses the same POM filename pattern (pom.xml, *.pom, *.pom.xml, bare pom, case-insensitive) and skips paths ignored by .gitignore or socket.yml projectIgnorePaths.

Build discovery returns BuildRoot objects (dir + optional entryFile) instead of directories only. Each matching POM is a separate Maven build; non-default files run with mvn --file, and reactor coverage is per POM file so one covered sibling does not hide another in the same folder.

The recursive manifest generator, DSI output, and socket manifest setup --recursive follow the same model: withEntryFileOpts prepends --file, partial --exclude-paths no longer disables an entire directory when another POM there stays included (with a warning), and the setup wizard prompts once per directory for multiple POMs.

Reviewed by Cursor Bugbot for commit 386e1a7. Configure here.

…ference

Maven build roots are discovered with the API's supported-file pattern for
POMs, case-insensitively as the upload matches it, instead of only pom.xml.
Each POM is its own build root: a non-default POM runs with `--file`, and
coverage by a parent build is judged per file. Discovery also applies
socket.yml's projectIgnorePaths, as the upload does, so a POM a scan would
not upload is not built either. --exclude-paths and .gitignore matching stay
case-sensitive.

The recursive setup wizard asks once per directory holding several POMs, and
no longer disables a whole directory when --exclude-paths matches only one of
its POMs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplification pass, no correctness findings. Comments are suggestions; none block.

Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/setup-recursive-manifest-config.mts Outdated
Comment thread src/commands/manifest/setup-recursive-manifest-config.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.test.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.test.mts
Comment thread src/commands/manifest/setup-recursive-manifest-config.test.mts Outdated
- Match build markers in the glob filter, POMs case-insensitively, instead of
  case-folding the pattern.
- Pass the POM to build as ManifestScriptOptions.entryFile; invokeMaven adds
  --file, and progress and failure messages name the POM.
- Resolve socket.yml once per caller and pass it to discovery.
- One table for file-addressed tools; one shared depth-then-path sort.
- Group setup-wizard candidates by directory: one prompt and one summary
  count per directory, each of its POMs enumerated unless already covered,
  including POMs at cwd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second simplification pass, on f7ae575. Most of the first round is addressed, thanks.

One correction first: in the last review I said moving discovery to **/* with a filter "shouldn't get slower". That was wrong. See the comment on the glob call. Directories walked are the same, but per-file matching cost goes up.

Outside this PR, for later: scanBuildRoots runs discovery twice even with no --exclude-paths. globWithGitIgnore could run filter before the !-pattern chain check. The scriptOpts builders in run-manifest-facts.mts and enumerate-workspaces.mts duplicate each other.

Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/scripts/run.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/discover-manifest-roots.mts Outdated
Comment thread src/commands/manifest/setup-recursive-manifest-config.mts Outdated
Comment thread src/commands/manifest/setup-recursive-manifest-config.mts Outdated
Comment thread src/commands/manifest/setup-recursive-manifest-config.test.mts Outdated
… config

- Move build-file names, the POM pattern and its case rule into one
  BUILD_FILES record; discovery walks narrow globs again and matches after.
- Build every discovered POM with its own --file; a user -f/--file in
  mavenOpts is dropped with a warning during config resolution.
- Resolve DSI and wizard settings once per directory.
- Require socketConfig for discovery, loaded through loadSocketConfig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

@jfblaa
Jeppe Fredsgaard Blaabjerg (jfblaa) merged commit ea8ec86 into v1.x Oct 27, 2026
10 checks passed
@jfblaa
Jeppe Fredsgaard Blaabjerg (jfblaa) deleted the jfblaa/dsi-maven-pom-pattern branch October 27, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants