2525 write_dependency_tree_log ,
2626)
2727from pombast .maven ._pom_rewriter import patch_pom_urls , rewrite_pom_versions
28+ from pombast .maven ._reactor import locate_module_dir
2829from pombast .maven ._scm import _guess_tag , resolve_scm
2930from pombast .util ._git import shallow_clone
3031
@@ -245,6 +246,7 @@ def run(self) -> ValidationReport:
245246 # which would otherwise cause pombast to reuse an old clone even after a
246247 # version bump in the BOM.
247248 sentinel = f"{ component .version } :{ tag } "
249+ fresh_clone = False
248250 if tag_file .exists () and tag_file .read_text ().strip () == sentinel :
249251 _log .info ("%s: reusing existing clone at %s" , component .coordinate , tag )
250252 else :
@@ -277,20 +279,52 @@ def run(self) -> ValidationReport:
277279 )
278280 )
279281 continue
282+ fresh_clone = True
283+
284+ # Locate the module subdirectory that builds this component. For a
285+ # multi-module project (e.g. BoneJ2, scijava/scijava) the BOM manages
286+ # each reactor module as its own component; pombast builds in the
287+ # matching subdirectory and lets sibling modules resolve from the
288+ # repository as ordinary released dependencies. For a single-module
289+ # project this is the clone root itself.
290+ build_dir = locate_module_dir (source_dir , component )
291+ if build_dir is None :
292+ _log .warning (
293+ "%s: no module POM matched in checkout — using clone root" ,
294+ component .coordinate ,
295+ )
296+ build_dir = source_dir
297+ elif build_dir != source_dir :
298+ _log .info (
299+ "%s: building module subdir %s" ,
300+ component .coordinate ,
301+ build_dir .relative_to (source_dir ),
302+ )
280303
281- # Patch and rewrite POM only for a fresh clone; re-applying to an
282- # already-patched POM would corrupt the pinned versions.
283- pom_file = source_dir / "pom.xml"
284- if pom_file .exists ():
285- patch_pom_urls (pom_file )
286- rewrite_pom_versions (pom_file , dep_mgmt )
304+ if fresh_clone :
305+ # Patch and rewrite POMs only for a fresh clone; re-applying to an
306+ # already-patched POM would corrupt the pinned versions. Upgrade
307+ # http→https across every POM in the checkout so inherited
308+ # repository URLs in parent/aggregator POMs don't break the build,
309+ # but pin versions only in this module's own POM — its own
310+ # dependencyManagement takes precedence over anything inherited,
311+ # so that is sufficient even when the module's parent lies outside
312+ # the reactor (as with scijava/scijava's pom-scijava-parented
313+ # modules).
314+ for pom in source_dir .rglob ("pom.xml" ):
315+ if "target" in pom .relative_to (source_dir ).parts :
316+ continue
317+ patch_pom_urls (pom )
318+ module_pom = build_dir / "pom.xml"
319+ if module_pom .exists ():
320+ rewrite_pom_versions (module_pom , dep_mgmt )
287321
288322 tag_file .write_text (sentinel + "\n " )
289323
290324 # Determine the build JDK from the rewritten (BOM-pinned) POM, so jgo
291325 # resolves exactly the dependency set Maven will build. A per-component
292326 # override wins; otherwise use the detected version, then the default.
293- analysis = analyze_build_java (component , ctx , source_dir / "pom.xml" )
327+ analysis = analyze_build_java (component , ctx , build_dir / "pom.xml" )
294328 comp_override = self .config .config .component_overrides .get (component .ga )
295329 if comp_override and "java-version" in comp_override :
296330 java_ver = comp_override ["java-version" ]
@@ -316,12 +350,14 @@ def run(self) -> ValidationReport:
316350 # Record the resolved dependency tree (with Java-version rationale) next
317351 # to the build logs, mirroring mega-melt's dependency-tree.log.
318352 write_dependency_tree_log (
319- analysis , component , source_dir / "dependency-tree.log"
353+ analysis , component , build_dir / "dependency-tree.log"
320354 )
321355
322356 # Build and test. The resolved closure from Java-version analysis
323357 # doubles as the success-cache key, so no second resolution is needed.
324- source = ComponentSource (component = component , source_dir = source_dir )
358+ source = ComponentSource (
359+ component = component , source_dir = source_dir , build_dir = build_dir
360+ )
325361 result = builder .build_and_test (
326362 source , closure = analysis .closure , extra_properties = comp_properties
327363 )
0 commit comments