Skip to content

Improve Maven POM resolution errors - #12320

Merged
jonathanpeppers merged 4 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-improve-maven-errors
Aug 11, 2026
Merged

Improve Maven POM resolution errors#12320
jonathanpeppers merged 4 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-improve-maven-errors

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

AndroidMavenLibrary resolution failures currently report the originally requested artifact even when a transitive parent or imported POM is missing. This makes repository mismatches difficult to diagnose.

Track the artifact at the failing LoggingPomResolver call and include its exact POM URL in XA4237. The existing localized XA4237 format remains compatible, while the new resolution detail uses a separate localizable resource. Documentation and deterministic imported-BOM coverage are included.

Fixes #9706

  • Useful description of why the change is necessary.
  • Links to issues fixed.
  • Unit tests (MavenDownloadTests: 18 passed).

jonathanpeppers and others added 2 commits August 7, 2026 14:47
Report the unresolved parent or imported POM artifact and the exact repository URL while retaining XA4237 and its localized resource contract.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move the new XA4237 resolution context into the resource catalog while preserving the existing translated XA4237 format contract.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 19:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves diagnostics for <AndroidMavenLibrary> POM resolution by reporting the actual artifact that failed during transitive/parent/imported POM resolution, and by including the exact POM URL in XA4237 to make repository mismatches actionable.

Changes:

  • Track the failing artifact inside LoggingPomResolver and emit XA4237 with a new localized “details” payload including unresolved artifact + POM URL.
  • Add deterministic unit coverage for imported-BOM failure reporting, and update existing XA4237 message assertions.
  • Update XA4237 documentation to reflect the expanded error detail.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/MavenDownloadTests.cs Updates XA4237 expectations and adds deterministic test coverage for transitive imported-POM failures (including URL capture).
src/Xamarin.Android.Build.Tasks/Tasks/MavenDownload.cs Adds unresolved artifact/URL tracking in the POM resolver and enriches XA4237 with localized resolution details.
src/Xamarin.Android.Build.Tasks/Properties/Resources.resx Adds a new localizable XA4237 details resource used to format resolution failures.
src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs Updates the generated resource accessor for the new XA4237 details string.
Documentation/docs-mobile/messages/xa4237.md Updates XA4237 documentation example and guidance to match the new diagnostics.
Documentation/docs-mobile/messages/index.md Updates the XA4237 index entry to reflect the expanded message shape.
Files not reviewed (1)
  • src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
Suppressed comments (1)

src/Xamarin.Android.Build.Tasks/Tasks/MavenDownload.cs:167

  • GetRepository uses the raw Repository metadata string for GetKnownRepository, Uri.TryCreate, and cache hashing without trimming whitespace, so values like " https://repo.example.com/maven2/" (or ones with trailing spaces) will fail URL detection and produce XA4239 even though the URL is otherwise valid. It also hashes the unnormalized URL, so a trailing slash creates a separate cache directory despite MavenRepository normalizing it.
		var type = item.GetMetadataOrDefault ("Repository", "Central");
		repositoryUrl = type.TrimEnd ('/');

		var repo = GetKnownRepository (type);
		if (repo == MavenRepository.Central)
			repositoryUrl = "https://repo1.maven.org/maven2";
		else if (repo == MavenRepository.Google)
			repositoryUrl = "https://dl.google.com/android/maven2";

		if (repo is null && Uri.TryCreate (type, UriKind.Absolute, out var uri) &&
			(uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)) {
			if (uri.Scheme == Uri.UriSchemeHttp &&

Comment thread src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Describe the structured unresolved-artifact details passed through the existing localized XA4237 placeholder.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Aug 10, 2026
@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) August 10, 2026 17:26
@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

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.

XA4237 can still falsely blame the root artifact in src/Xamarin.Android.Build.Tasks/Tasks/MavenDownload.cs (around lines 131-134). A successfully loaded transitive parent or imported BOM can fail during model resolution before LoggingPomResolver records another artifact, leaving the resolver details null and causing the fallback to report the original root POM URL. Please avoid synthesizing root details for that path or track the active transitive POM, and add a deterministic nested parent/import regression test.

Only include unresolved artifact and repository URL details when LoggingPomResolver observed an actual retrieval or parse failure. Preserve the underlying model-resolution error otherwise.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers

Copy link
Copy Markdown
Member Author

Addressed the requested change in cbeda7f. XA4237 now adds unresolved artifact/POM URL context only when LoggingPomResolver actually observed a retrieval or parse failure. If all nested POMs loaded and a later model-resolution step fails, it reports the underlying exception without fabricating root artifact details. Added a deterministic imported-BOM regression where both POMs load before nested model resolution fails; all 19 MavenDownload tests pass.

@dalexsoto dalexsoto left a comment

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.

Re-reviewed the current changes. Artifact and POM URL context is now emitted only for actual retrieval or parse failures, so nested model-resolution failures no longer fabricate root POM details. The deterministic imported-BOM regression covers the prior concern. No blocking issues found.

@jonathanpeppers

Copy link
Copy Markdown
Member Author

There is one flaky test failure, can be ignored:

image

@jonathanpeppers
jonathanpeppers merged commit 7776e47 into dotnet:main Aug 11, 2026
42 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve AndroidMavenLibrary dependency resolution error messaging

3 participants