Improve Maven POM resolution errors - #12320
Conversation
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>
There was a problem hiding this comment.
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
LoggingPomResolverand 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
GetRepositoryuses the rawRepositorymetadata string forGetKnownRepository,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 despiteMavenRepositorynormalizing 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 &&
Describe the structured unresolved-artifact details passed through the existing localized XA4237 placeholder. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
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>
|
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
left a comment
There was a problem hiding this comment.
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.

AndroidMavenLibraryresolution 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
LoggingPomResolvercall 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
MavenDownloadTests: 18 passed).