Skip to content

Commit 3c5eced

Browse files
authored
feat(manifest): name failing JVM dependencies and remedies the command accepts (#1638)
* feat(manifest): name failing JVM dependencies and remedies the command accepts When dependency resolution fails, the report now names the dependency that failed, the subproject and scope that needed it, and only remedies the invoking command actually accepts: - Single-build manifest commands suggest their flags; `socket manifest dynamic-sbom-inference` gains --ignore-unresolved; scan/fix/auto-manifest point at the failing build's own socket.json and its setup wizard. - Maven no longer reports a dependency-graph failure as a `graph` configuration against the module itself: it names the failing dependency and the scope it has in the graph, so excluding that scope clears it. - Unresolved dependencies are reported and left out of the facts for Maven, Gradle and sbt alike. sbt retries leniently instead of excluding modules, so an unresolved dependency no longer empties the whole project. - socket.json `verbose` is honored on the dynamic-sbom-inference path, a build tool that cannot start says why, and scan create/reach warn about build flags they read from socket.json instead. * test(manifest): put each compat JDK on PATH so sbt rows use it The sbt launcher runs java from PATH and ignores JAVA_HOME, so every sbt row ran on whatever JDK came first on PATH (and sbt 0.13 failed on a modern one). * fix(manifest): print a usable socket.json path and skip an empty abort warning A build root outside the shell's directory got a socket.json hint that climbed to the filesystem root; it now gets the absolute path. A failed last build root no longer warns that the remaining roots cannot be classified. * fix(manifest): stream build-tool output to stderr With verbose set in socket.json, Maven's log was inherited onto stdout and broke --json output. Streamed build output is a diagnostic, so it now goes to stderr on every path. * fix(manifest): give each sbt failure its own module's message Every failure carried the whole batch resolve message, so the records grew quadratically with the number of failed modules. Each failure now keeps only its module's part of the message.
1 parent 28dabe1 commit 3c5eced

36 files changed

Lines changed: 1160 additions & 186 deletions

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [Unreleased]
8+
9+
### Added
10+
- `socket manifest dynamic-sbom-inference --ignore-unresolved` keeps going past unresolved JVM dependencies in every discovered build.
11+
12+
### Fixed
13+
- `--dynamic-sbom-inference` honors each build's `verbose` setting in `socket.json`.
14+
- JVM resolution failures name the dependency that failed, the subproject and scope that needed it, and suggest only options the command you ran accepts, pointing at the failing build's own `socket.json`.
15+
- Unresolved JVM dependencies are reported and left out of the Socket facts for Maven, Gradle and sbt alike, as far as each build tool identifies them; a Maven dependency in an excluded scope no longer blocks the run.
16+
- An sbt project with an unresolved dependency keeps the rest of its dependencies instead of silently losing all of them.
17+
- `socket scan create` and `socket scan reach` warn about `--ignore-unresolved`, `--exclude-configs`, `--include-configs` and `--verbose`, which they read from `socket.json` instead.
18+
- When a build tool cannot be started, the error says why, for example a missing `mvn`.
19+
720
## [1.9.1](https://github.com/SocketDev/socket-cli/releases/tag/v1.9.1) - 2026-10-21
821

922
### Changed

‎src/commands/manifest/cmd-manifest-dynamic-sbom-inference.mts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ const config: CliCommandConfig = {
2727
...commonFlags,
2828
...outputFlags,
2929
...excludePathsFlag,
30+
ignoreUnresolved: {
31+
type: 'boolean',
32+
description:
33+
"Warn on unresolved dependencies instead of failing the run (unresolved deps are not emitted to the facts files); overrides each build's socket.json setting",
34+
},
3035
verbose: {
3136
type: 'boolean',
3237
default: false,
@@ -76,11 +81,13 @@ async function run(
7681

7782
const {
7883
dryRun,
84+
ignoreUnresolved,
7985
json,
8086
markdown,
8187
verbose: verboseFlag,
8288
} = cli.flags as {
8389
dryRun: boolean
90+
ignoreUnresolved: boolean | undefined
8491
json: boolean
8592
markdown: boolean
8693
verbose: boolean | undefined
@@ -134,6 +141,7 @@ async function run(
134141
await handleManifestDynamicSbomInference({
135142
cwd,
136143
excludePaths,
144+
ignoreUnresolved,
137145
outputKind,
138146
verbose,
139147
})

‎src/commands/manifest/cmd-manifest-dynamic-sbom-inference.test.mts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('socket manifest dynamic-sbom-inference', async () => {
3434
3535
Options
3636
--exclude-paths List of glob patterns to exclude from manifest/facts generation. Patterns are anchored micromatch globs matched relative to CWD (\`--cwd\` if set): \`tests\` matches only \`<cwd>/tests\`; use \`**/tests\` to match at any depth. Negation patterns (\`!path\`) are not supported. Accepts a comma-separated value or multiple flags.
37+
--ignore-unresolved Warn on unresolved dependencies instead of failing the run (unresolved deps are not emitted to the facts files); overrides each build's socket.json setting
3738
--json Output as JSON
3839
--markdown Output as Markdown
3940
--verbose Print debug messages

‎src/commands/manifest/convert-gradle-to-facts.mts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { runManifestFacts } from './run-manifest-facts.mts'
22

3+
import type { BuildOptionHints } from './scripts/resolution-report-render.mts'
34
import type { SidecarAccumulator } from './scripts/sidecar.mts'
45

56
// Generates `gradle.socket.facts.json` for a Gradle project via the bundled
@@ -10,6 +11,7 @@ export async function convertGradleToFacts({
1011
excludeConfigs,
1112
excludePaths,
1213
gradleOpts,
14+
hints,
1315
ignoreUnresolved,
1416
includeConfigs,
1517
javaHome,
@@ -22,6 +24,7 @@ export async function convertGradleToFacts({
2224
excludeConfigs: string
2325
excludePaths?: string[] | undefined
2426
gradleOpts: string[]
27+
hints?: BuildOptionHints | undefined
2528
ignoreUnresolved: boolean
2629
includeConfigs: string
2730
javaHome?: string | undefined
@@ -36,6 +39,7 @@ export async function convertGradleToFacts({
3639
ecosystem: 'gradle',
3740
excludeConfigs,
3841
excludePaths,
42+
hints,
3943
ignoreUnresolved,
4044
includeConfigs,
4145
javaHome,

‎src/commands/manifest/convert-maven-to-facts.mts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { runManifestFacts } from './run-manifest-facts.mts'
22

3+
import type { BuildOptionHints } from './scripts/resolution-report-render.mts'
34
import type { SidecarAccumulator } from './scripts/sidecar.mts'
45

56
// Generates `pom.xml.socket.facts.json` (named after the POM Maven runs on)
@@ -9,6 +10,7 @@ export async function convertMavenToFacts({
910
cwd,
1011
excludeConfigs,
1112
excludePaths,
13+
hints,
1214
ignoreUnresolved,
1315
includeConfigs,
1416
javaHome,
@@ -21,6 +23,7 @@ export async function convertMavenToFacts({
2123
cwd: string
2224
excludeConfigs: string
2325
excludePaths?: string[] | undefined
26+
hints?: BuildOptionHints | undefined
2427
ignoreUnresolved: boolean
2528
includeConfigs: string
2629
javaHome?: string | undefined
@@ -36,6 +39,7 @@ export async function convertMavenToFacts({
3639
ecosystem: 'maven',
3740
excludeConfigs,
3841
excludePaths,
42+
hints,
3943
ignoreUnresolved,
4044
includeConfigs,
4145
javaHome,

‎src/commands/manifest/convert-sbt-to-facts.mts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { runManifestFacts } from './run-manifest-facts.mts'
22

3+
import type { BuildOptionHints } from './scripts/resolution-report-render.mts'
34
import type { SidecarAccumulator } from './scripts/sidecar.mts'
45

56
// Generates `sbt.socket.facts.json` for an sbt project via the bundled sbt plugin.
@@ -10,6 +11,7 @@ export async function convertSbtToFacts({
1011
cwd,
1112
excludeConfigs,
1213
excludePaths,
14+
hints,
1315
ignoreUnresolved,
1416
includeConfigs,
1517
javaHome,
@@ -23,6 +25,7 @@ export async function convertSbtToFacts({
2325
cwd: string
2426
excludeConfigs: string
2527
excludePaths?: string[] | undefined
28+
hints?: BuildOptionHints | undefined
2629
ignoreUnresolved: boolean
2730
includeConfigs: string
2831
javaHome?: string | undefined
@@ -40,6 +43,7 @@ export async function convertSbtToFacts({
4043
ecosystem: 'sbt',
4144
excludeConfigs,
4245
excludePaths,
46+
hints,
4347
ignoreUnresolved,
4448
includeConfigs,
4549
javaHome,

‎src/commands/manifest/enumerate-workspaces.mts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ export async function enumerateWorkspaces({
6767
} catch (e) {
6868
process.exitCode = 1
6969
logger.fail(
70-
`Could not run the ${ecosystem} build tool` +
71-
(verbose
72-
? `: ${getErrorMessageOr(e, String(e))}`
73-
: ' (run with --verbose for details).'),
70+
`Could not run the ${ecosystem} build tool: ${getErrorMessageOr(e, String(e))}`,
7471
)
7572
return
7673
}

‎src/commands/manifest/generate-recursive-manifests.mts‎

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
import { parseBuildToolOpts } from './parse-build-tool-opts.mts'
1313
import { runManifestFacts } from './run-manifest-facts.mts'
1414
import { resolveBuildToolBin } from './scripts/build-tool.mts'
15+
import { DSI_SETUP_COMMAND } from './scripts/resolution-report-render.mts'
16+
import { SOCKET_JSON } from '../../constants.mts'
1517
import { withTmpDir } from '../../utils/fs.mts'
1618
import {
1719
readOrDefaultSocketJson,
@@ -20,6 +22,7 @@ import {
2022
import { projectIgnorePathsToReachExcludePaths } from '../scan/exclude-paths.mts'
2123

2224
import type { BuildTool } from './scripts/build-tool.mts'
25+
import type { BuildOption } from './scripts/resolution-report-render.mts'
2326
import type { SidecarAccumulator } from './scripts/sidecar.mts'
2427
import type { SocketJson } from '../../utils/socket-json.mts'
2528

@@ -47,21 +50,29 @@ export type EcosystemBuildConfig = {
4750
javaHome: string | undefined
4851
// Set when this build root should be skipped entirely (never invoked).
4952
skipReason: string | undefined
53+
verbose: boolean
54+
}
55+
56+
// Relative to the user's shell when inside it, else absolute.
57+
function displayPath(file: string): string {
58+
const rel = path.relative(process.cwd(), file)
59+
return rel.startsWith('..') || path.isAbsolute(rel) ? file : rel
5060
}
5161

5262
// A cascaded (not just root-level) disabled additionally skips this one build
5363
// root here, on top of its existing root-only ecosystem-wide meaning for
5464
// auto/gradle/etc. facts:false has no pom-mode equivalent here (facts-only),
5565
// so it skips too.
5666
function getSkipReason(
67+
ecosystem: BuildTool,
5768
disabled: boolean | undefined,
5869
facts?: boolean | undefined,
5970
): string | undefined {
6071
if (disabled) {
61-
return 'defaults.manifest.<ecosystem>.disabled is true'
72+
return `defaults.manifest.${ecosystem}.disabled is true`
6273
}
6374
if (facts === false) {
64-
return 'defaults.manifest.<ecosystem>.facts is false (pom mode)'
75+
return `defaults.manifest.${ecosystem}.facts is false (pom mode)`
6576
}
6677
return undefined
6778
}
@@ -90,6 +101,8 @@ function nearestDisabledRoot(
90101
async function runEcosystemCandidates({
91102
candidatesByTool,
92103
excludePaths,
104+
ignoreUnresolved: ignoreUnresolvedOverride,
105+
optionFlags,
93106
realCwd,
94107
rootSockJson,
95108
sbtTmpDir,
@@ -99,6 +112,8 @@ async function runEcosystemCandidates({
99112
}: {
100113
candidatesByTool: Map<BuildTool, string[]>
101114
excludePaths: string[] | undefined
115+
ignoreUnresolved: boolean | undefined
116+
optionFlags: ReadonlySet<BuildOption>
102117
realCwd: string
103118
rootSockJson: SocketJson
104119
// sbt only: a shared global base reused across every sbt root in this run,
@@ -133,6 +148,7 @@ async function runEcosystemCandidates({
133148
includeConfigs,
134149
javaHome,
135150
skipReason,
151+
verbose: configVerbose,
136152
} = resolveEcosystemConfig(ecosystem, dir, sockJson)
137153

138154
if (skipReason) {
@@ -162,21 +178,29 @@ async function runEcosystemCandidates({
162178
ecosystem,
163179
excludeConfigs,
164180
excludePaths: excludePathsForRoot,
165-
ignoreUnresolved,
181+
hints: {
182+
flags: optionFlags,
183+
setupCommand: DSI_SETUP_COMMAND,
184+
socketJson: displayPath(path.join(dir, SOCKET_JSON)),
185+
},
186+
ignoreUnresolved: ignoreUnresolvedOverride ?? ignoreUnresolved,
166187
includeConfigs,
167188
javaHome,
168189
sidecarAcc,
169190
tmpDir: ecosystem === 'sbt' ? sbtTmpDir : undefined,
170-
verbose,
191+
verbose: verbose || configVerbose,
171192
withFiles,
172193
})
173194

174195
if (result === null) {
175196
outcomes.push({ dir, ecosystem, status: 'failed' })
176-
logger.warn(
177-
`Aborting ${ecosystem} discovery: ${dir}'s workspace layout could not be determined, so its remaining build roots cannot be safely classified as covered or independent.`,
178-
)
179-
for (const abortedDir of dirs.slice(dirIndex + 1)) {
197+
const abortedDirs = dirs.slice(dirIndex + 1)
198+
if (abortedDirs.length) {
199+
logger.warn(
200+
`Aborting ${ecosystem} discovery: ${dir} failed to generate Socket facts, and without them the remaining build roots cannot be safely classified as covered or independent.`,
201+
)
202+
}
203+
for (const abortedDir of abortedDirs) {
180204
outcomes.push({ dir: abortedDir, ecosystem, status: 'aborted' })
181205
}
182206
break
@@ -209,13 +233,20 @@ async function runEcosystemCandidates({
209233
export async function generateRecursiveManifests({
210234
cwd,
211235
excludePaths,
236+
ignoreUnresolved,
237+
optionFlags = new Set(),
212238
sbtTmpDir,
213239
sidecarAcc,
214240
verbose,
215241
withFiles,
216242
}: {
217243
cwd: string
218244
excludePaths?: string[] | undefined
245+
// When set, overrides every build root's own socket.json setting.
246+
ignoreUnresolved?: boolean | undefined
247+
// Options the invoking command takes as flags; hints send the rest to each
248+
// build root's socket.json.
249+
optionFlags?: ReadonlySet<BuildOption> | undefined
219250
// Reachability path only: caller-supplied directory to use as sbt's shared
220251
// global base across every sbt root in this run. sbt provisions the Scala
221252
// toolchain under `<base>/boot`, which withFiles' artifactPaths point into,
@@ -250,6 +281,8 @@ export async function generateRecursiveManifests({
250281
runEcosystemCandidates({
251282
candidatesByTool,
252283
excludePaths,
284+
ignoreUnresolved,
285+
optionFlags,
253286
realCwd,
254287
rootSockJson,
255288
sbtTmpDir: resolvedSbtTmpDir,
@@ -296,7 +329,8 @@ export function resolveEcosystemConfig(
296329
ignoreUnresolved: Boolean(config?.ignoreUnresolved),
297330
includeConfigs: config?.includeConfigs ?? '',
298331
javaHome: config?.javaHome ?? undefined,
299-
skipReason: getSkipReason(config?.disabled, config?.facts),
332+
skipReason: getSkipReason(ecosystem, config?.disabled, config?.facts),
333+
verbose: Boolean(config?.verbose),
300334
}
301335
}
302336
if (ecosystem === 'gradle') {
@@ -309,7 +343,8 @@ export function resolveEcosystemConfig(
309343
ignoreUnresolved: Boolean(config?.ignoreUnresolved),
310344
includeConfigs: config?.includeConfigs ?? '',
311345
javaHome: config?.javaHome ?? undefined,
312-
skipReason: getSkipReason(config?.disabled, config?.facts),
346+
skipReason: getSkipReason(ecosystem, config?.disabled, config?.facts),
347+
verbose: Boolean(config?.verbose),
313348
}
314349
}
315350
const config = sockJson.defaults?.manifest?.maven
@@ -321,6 +356,7 @@ export function resolveEcosystemConfig(
321356
ignoreUnresolved: Boolean(config?.ignoreUnresolved),
322357
includeConfigs: config?.includeConfigs ?? '',
323358
javaHome: config?.javaHome ?? undefined,
324-
skipReason: getSkipReason(config?.disabled),
359+
skipReason: getSkipReason(ecosystem, config?.disabled),
360+
verbose: Boolean(config?.verbose),
325361
}
326362
}

0 commit comments

Comments
 (0)