Skip to content

Commit 6019185

Browse files
committed
fix: wire --bazel-maven-repo flag for custom WORKSPACE hubs and fix empty show_extension fallback
Bug 1: Legacy WORKSPACE projects with non-conventional maven_install names (e.g. maven_legacy_app) were no longer discovered because the CLI never exposed --bazel-maven-repo to pass extraMavenRepoNames. Add the flag to cmd-manifest-bazel.mts, support it in socket.json defaults, and plumb it through the auto-manifest pathway. Bug 2: When bazel mod show_extension exits 0 but parseShowExtensionOutput returns no hub names (format mismatch or empty report), discovery skipped the conventional probe fallback. Now showExtensionSucceeded is only set when parsed hubs are non-empty, so the conventional names are still probed.
1 parent 414a9a6 commit 6019185

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

src/commands/manifest/bazel/cmd-manifest-bazel.mts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ const config: CliCommandConfig = {
5151
description:
5252
'Flags forwarded to every bazel invocation (single quoted string)',
5353
},
54+
bazelMavenRepo: {
55+
type: 'string',
56+
isMultiple: true,
57+
description:
58+
'Extra Maven hub repo name(s) to probe; repeatable. Use for legacy WORKSPACE projects whose maven_install uses a non-conventional name.',
59+
},
5460
bazelOutputBase: {
5561
type: 'string',
5662
description: 'Bazel --output_base for read-only-cache CI environments',
@@ -202,7 +208,7 @@ async function run(
202208
sockJson?.defaults?.manifest?.bazel,
203209
)
204210

205-
const { ecosystem } = cli.flags
211+
const { bazelMavenRepo, ecosystem } = cli.flags
206212
let { bazel, bazelFlags, bazelOutputBase, bazelRc, out, verbose } = cli.flags
207213

208214
// Set defaults for any flag/arg that is not given. Check socket.json first.
@@ -260,6 +266,12 @@ async function run(
260266
}
261267
}
262268

269+
// Compose extra Maven repo names from the CLI flag and socket.json defaults.
270+
const extraMavenRepoNames: string[] = [
271+
...(Array.isArray(bazelMavenRepo) ? bazelMavenRepo : []),
272+
...(sockJson.defaults?.manifest?.bazel?.bazelMavenRepo ?? []),
273+
].filter(Boolean)
274+
263275
if (verbose) {
264276
logger.group('- ', parentName, config.commandName, ':')
265277
logger.group('- flags:', cli.flags)
@@ -318,6 +330,9 @@ async function run(
318330
bazelRc: bazelRc as string | undefined,
319331
bin: bazel as string | undefined,
320332
cwd,
333+
extraMavenRepoNames: extraMavenRepoNames.length
334+
? extraMavenRepoNames
335+
: undefined,
321336
ignoreDirNames: BAZEL_WALKER_IGNORE_DIR_NAMES,
322337
ignoreDirPrefixes: BAZEL_WALKER_IGNORE_DIR_PREFIXES,
323338
out: out as string,

src/commands/manifest/bazel/extract_bazel_to_maven.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,12 @@ async function discoverCandidatesForWorkspace(
260260
if (mode.bzlmod) {
261261
const extResult = await runBazelModShowMavenExtension(queryOpts)
262262
if (extResult.code === 0) {
263-
candidates.push(...parseShowExtensionOutput(extResult.stdout))
264-
showExtensionSucceeded = true
263+
const parsedHubs = parseShowExtensionOutput(extResult.stdout)
264+
candidates.push(...parsedHubs)
265+
// Only consider successful when hubs were actually parsed; a zero
266+
// exit with no recognized hub names (format mismatch, empty report)
267+
// should still fall back to conventional probing.
268+
showExtensionSucceeded = parsedHubs.length > 0
265269
if (verbose) {
266270
logger.log(
267271
`[VERBOSE] workspace ${workspaceRoot}: show_extension yielded`,

src/commands/manifest/generate_auto_manifest.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export async function generateAutoManifest({
129129
bazelRc: bazelConfig?.bazelRc,
130130
bin: bazelConfig?.bazel ?? bazelConfig?.bin,
131131
cwd,
132+
extraMavenRepoNames: bazelConfig?.bazelMavenRepo,
132133
out: bazelConfig?.out ?? cwd,
133134
outLayout: 'flat',
134135
verbose: Boolean(bazelConfig?.verbose) || verbose,

src/utils/socket-json.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface SocketJson {
4242
bazel?: {
4343
bazel?: string | undefined
4444
bazelFlags?: string | undefined
45+
bazelMavenRepo?: string[] | undefined
4546
bazelOutputBase?: string | undefined
4647
bazelRc?: string | undefined
4748
bin?: string | undefined

0 commit comments

Comments
 (0)