Skip to content

[tests] Isolate Maven resolution on CI#12199

Open
jonathanpeppers wants to merge 8 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-fix-cfsclean-maven-feeds
Open

[tests] Isolate Maven resolution on CI#12199
jonathanpeppers wants to merge 8 commits into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-fix-cfsclean-maven-feeds

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed - N/A
  • Unit tests

Summary

CFSClean reports test jobs that resolve Maven dependencies and Gradle plugins directly from public services. CI must instead use the anonymous dotnet-public-maven Azure Artifacts feed without falling back to public repositories, while local development should retain the existing public repository behavior.

This change centralizes that policy around the existing RUNNINGONCI convention:

  • Xamarin.ProjectTools rewrites Maven Central and Google test downloads to the CI feed and generated Gradle settings apply the shared eng/gradle repository scripts.
  • MavenDownload, AndroidMavenLibrary, device integration, and Java.Interop Maven tests select the mirror only on CI.
  • Generated tests avoid downloading alternate Gradle distributions on CI, and Java.Interop java-source-utils no longer declares mavenCentral() independently.
  • mirror-dependencies.ps1 gains a direct Maven coordinate mode for seeding tests that do not use Gradle.

No public-network fallback is present on CI. Anonymous probes identified uncached test artifacts, which must be seeded with the mirror helper before those CI cases can pass.

Testing

  • Built Xamarin.ProjectTools, Xamarin.Android.Build.Tests, and MSBuildDeviceIntegration.
  • Passed all 11 MavenDownloadTests locally.
  • Passed the available CI-mode MavenDownload subset: 7 passed and 2 expected 404-only tests skipped; 2 artifact-resolution cases are blocked only by uncached feed packages.
  • Passed 106 Java.Interop Maven tests.
  • Resolved java-source-utils dependencies through the CI feed.
  • Validated generated Kotlin settings use only dotnet-public-maven; resolution reached the expected uncached AGP 9.1.1 marker.

Route test Maven and Gradle resolution through dotnet-public-maven when
RUNNINGONCI is set while retaining public repositories for local development.
Teach generated Gradle projects to use the shared repository configuration and
extend the mirror helper for tests that resolve Maven files without Gradle.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d21fe48a-552e-44ca-8c0b-739e7c2b7129
Copilot AI review requested due to automatic review settings July 21, 2026 19:07

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 updates test infrastructure and Gradle test projects to ensure Maven/Gradle dependency resolution on CI uses the anonymous dotnet-public-maven Azure Artifacts mirror (per RUNNINGONCI=true) rather than reaching out to public repositories, while keeping existing public-repo behavior for local development.

Changes:

  • Centralizes CI detection and Maven URL rewriting in Xamarin.ProjectTools.TestEnvironment, and routes DownloadedCache downloads through it.
  • Updates multiple test suites to select the Maven mirror on CI and to skip/adjust assertions for behaviors that differ on the mirror (e.g., uncached artifacts returning 401).
  • Aligns generated and in-repo Gradle settings.gradle(.kts) with shared eng/gradle/*-repositories.gradle scripts; extends mirror-dependencies.ps1 to support direct Maven coordinate seeding.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs Ensures AndroidMavenLibrary items use the CI mirror via TestEnvironment when running on CI.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/TestEnvironment.cs Adds RUNNINGONCI detection and helpers to select the mirror and rewrite Maven Central/Google download URLs on CI.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DownloadedCache.cs Rewrites download URLs through TestEnvironment.GetTestDownloadUrl() to enforce mirror usage on CI.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidGradleProject.cs Generates settings.gradle.kts using shared eng/gradle repository scripts and avoids downloading alternate Gradle distributions on CI.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/MavenDownloadTests.cs Switches to TestEnvironment mirror selection on CI; skips tests whose expected 404 behavior differs on the mirror; removes null-forgiving usage in touched code.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs Sets Maven repository metadata via TestEnvironment to enforce mirror usage on CI.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidGradleProjectTests.cs Skips multi-Gradle-version test cases on CI to avoid public Gradle distribution downloads.
external/Java.Interop/tools/java-source-utils/settings.gradle Uses shared eng/gradle repository scripts for plugin/dependency resolution.
external/Java.Interop/tools/java-source-utils/build.gradle Removes per-project repositories { mavenCentral() } to rely on shared settings-based repository policy.
external/Java.Interop/tests/Java.Interop.Tools.Maven-Tests/Extensions/MavenProjectResolver.cs Selects the mirror repository on CI for Java.Interop Maven tests while keeping existing local behavior.
eng/gradle/mirror-dependencies.ps1 Adds -MavenArtifact mode to seed the mirror directly for tests that fetch Maven artifacts without Gradle.
.github/instructions/gradle.instructions.md Documents the new direct Maven-coordinate seeding mode for the mirror helper script.

Put each importing test project Kotlin intermediates under its own obj directory so concurrent solution builds cannot remove another compiler classpath snapshot.

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

Copilot-Session: d21fe48a-552e-44ca-8c0b-739e7c2b7129
Select the Gradle executable already installed on CI agents so Java.Interop test builds do not download a distribution from services.gradle.org. Local builds continue using the repository wrapper.

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

Copilot-Session: d21fe48a-552e-44ca-8c0b-739e7c2b7129
Hosted Windows and macOS agents do not provide Gradle on PATH. Remove the preinstalled-Gradle override so Java.Interop jobs use their checked-in wrapper again while the isolated Gradle distribution awaits feed seeding.

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

Copilot-Session: d21fe48a-552e-44ca-8c0b-739e7c2b7129
Run restore out of process before BootstrapTasks and workloads builds. This ensures generated NuGet path properties are imported on clean agents instead of evaluating MonoUnixNative.targets with an empty PkgMono_Unix path.

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

Copilot-Session: d21fe48a-552e-44ca-8c0b-739e7c2b7129
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@jonathanpeppers

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Authenticate Azure Artifacts Maven requests with the Azure DevOps OAuth token as a Basic credential, and disable Gradle configuration caching while the credential provider runs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d21fe48a-552e-44ca-8c0b-739e7c2b7129
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Run mirror resolution anonymously with configuration caching enabled so it discovers the same lazy Kotlin and lint classpaths as CI. Seed each 401 through the authenticated HTTP path instead of loading a Gradle credential provider.

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

Copilot-Session: d21fe48a-552e-44ca-8c0b-739e7c2b7129
Pin BindFacebook to the mirrored 18.3.0 release and teach the mirror helper to seed payloads that Gradle probes with HEAD as well as GET.

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

Copilot-Session: d21fe48a-552e-44ca-8c0b-739e7c2b7129
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.

3 participants