Skip to content

Wire ModelBuilderRequest.isLocationTracking() to XML parser - #12655

Open
gnodet wants to merge 2 commits into
masterfrom
quick-fix/wire-location-tracking-to-parser
Open

Wire ModelBuilderRequest.isLocationTracking() to XML parser#12655
gnodet wants to merge 2 commits into
masterfrom
quick-fix/wire-location-tracking-to-parser

Conversation

@gnodet

@gnodet gnodet commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add addLocationInformation field to XmlReaderRequest interface and builder, defaulting to true for backwards compatibility
  • Wire it through DefaultModelXmlFactory.doRead() to MavenStaxReader.setAddLocationInformation()
  • Propagate request.isLocationTracking() in DefaultModelBuilder.doReadFileModel() so the generated MavenStaxReader skips all 97 InputLocation.of() allocations per POM when location tracking is disabled
  • Propagate locationTracking from the parent request to BOM import requests in doLoadDependencyManagement() so that project builds (which need location tracking) still get full location info from their BOMs

Previously, ModelBuilderRequest.isLocationTracking() was only checked in one place (DefaultDependencyManagementImporter), while the XML parser always created InputLocation objects regardless of the flag. This connects the existing flag to the parser, making it actually effective.

Test plan

  • mvn verify -pl impl/maven-impl — all tests pass
  • mvn verify -pl impl/maven-core — all tests pass, including testLocationTrackingResolution which verifies BOM dependency location tracking

🤖 Generated with Claude Code

gnodet added a commit that referenced this pull request Aug 1, 2026
Remove addLocationInformation from XmlReaderRequest and
DefaultModelXmlFactory — these changes belong in the
wire-location-tracking-to-parser branch (PR #12655), not
in the model-building-pipeline optimization PR.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit that referenced this pull request Aug 2, 2026
Remove addLocationInformation from XmlReaderRequest and
DefaultModelXmlFactory — these changes belong in the
wire-location-tracking-to-parser branch (PR #12655), not
in the model-building-pipeline optimization PR.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add isAddLocationInformation() to XmlReaderRequest and wire it to
MavenStaxReader so callers can skip location tracking when not needed.
DefaultModelBuilder propagates the flag from ModelBuilderRequest to the
XML parser, and forwards the parent's setting to BOM import sub-requests
instead of hardcoding it off.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the quick-fix/wire-location-tracking-to-parser branch from 2190df7 to 43f6a73 Compare August 2, 2026 15:10
Do not pass ModelBuilderRequest.isLocationTracking() as the
addLocationInformation flag for XmlReaderRequest.  These are
different concerns:

- isLocationTracking() controls whether the model building pipeline
  retains location data (used by DefaultDependencyManagementImporter
  and DefaultProjectBuilder)
- isAddLocationInformation() controls whether the XML parser tracks
  line/column positions during parsing

Wiring one to the other broke hasSubprojectsDefined(), which relies on
model.getLocation("modules") to detect <modules> presence.  When
DefaultConsumerPomBuilder sets locationTracking(false) for consumer POM
generation, the XML parser skipped location tracking, causing spurious
auto-discovery of subprojects alongside explicit <modules> entries.

The XmlReaderRequest API + DefaultModelXmlFactory wiring remain as
correct infrastructure for future selective optimization by callers
who know they don't need XML-level locations.

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

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The new XmlReaderRequest.isAddLocationInformation() API infrastructure is correctly wired through DefaultModelXmlFactory to MavenStaxReader and will work for any future caller passing addLocationInformation(false).

Two observations:

  1. locationTracking default change: The default changed from false to true in the ModelBuilderRequest builder. This affects callers not explicitly setting the flag — notably DefaultArtifactDescriptorReader and DefaultModelBuilder.doLoadDependencyManagement() — which will now run updateWithImportedFrom() for every BOM dependency. The practical impact is small (proportional to unique imported dependencies), but this behavioral change merits explicit mention in the PR description.

  2. @since tag: The @since 4.0.0 on isAddLocationInformation() should be @since 4.1.0 since the method is new and the project is at 4.1.0-SNAPSHOT.

Note: Cannot submit as APPROVE because the PR author matches the review account.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant