Repository navigation
[xabt] Enable MT for ValidateJavaVersion - #13322
Merged
jonathanpeppers merged 4 commits intoOct 30, 2026
Merged
Conversation
ValidateJavaVersion starts Java processes and reads JDK files, so it cannot safely use the shared process directory and environment in MT builds. Use MultithreadedAndroidTask and TaskEnvironment for both. Read stdout and stderr separately, and key cached versions by the tool path, project directory, and Java options. Keep the configured JDK bounds and diagnostics. Add focused path, environment, and cache tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the multithreaded Java version validation changes.
No open issues 🎉
What changed in this PR
Updates ValidateJavaVersion to support in-process multithreaded MSBuild execution while preserving JDK version bounds and diagnostics.
Changes:
- Uses
MultithreadedAndroidTaskand project-specific paths and process environments. - Reads stdout and stderr separately and scopes cached versions by tool path, project directory, and Java options.
- Adds tests for relative paths, environment isolation, and normalized-path cache reuse.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ValidateJavaVersionTests.cs | Adds project-context tests and extends cache reuse coverage. |
| src/Xamarin.Android.Build.Tasks/Tasks/ValidateJavaVersion.cs | Enables multithreaded execution with project-aware tool resolution, process launch, and caching. |
Review effort: Balanced
jonathanpeppers
commented
Oct 29, 2026
Add a TaskEnvironment overload to the existing process helper. Keep Java output collection in the original shared buffer, protect its callbacks with a lock, and remove the project directory cache key. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Do not query special folders when initializing the OS flags. Resolve and cache ProgramFilesX86 only when it is requested, so MT tasks can continue to use OS.IsWindows without environment-dependent setup. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival
approved these changes
Oct 30, 2026
jonathanpeppers
deleted the
jonathanpeppers-mt-java-version-validation
branch
October 30, 2026 14:51
jonathanpeppers
added a commit
that referenced
this pull request
Oct 30, 2026
Stacked on #13322. Reuse its `MonoAndroidHelper.RunProcess(TaskEnvironment, …)` overload for the aapt2 version probe. `ResolveAndroidTooling` still requires process-wide working-directory and environment handling under `-mt`. Use `MultithreadedAndroidTask` and declare `[MSBuildMultiThreadableTask]` so it can run in-process with other tasks. Resolve SDK and tool paths through `TaskEnvironment`, use project-specific `PATHEXT`, and start aapt2 with the project environment. Keep the existing tool search order and diagnostics. Extend the existing cache test to cover distinct project directories, relative paths, child-process environment and working directory, and cache reuse. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable in-process
-mtexecution forValidateJavaVersion. UseMultithreadedAndroidTask, declare[MSBuildMultiThreadableTask], and add aTaskEnvironmentoverload toMonoAndroidHelper.RunProcessfor the project's working directory and environment.Keep the existing output callbacks and buffer, with locks for concurrent writes. Resolve tool paths before release-file lookup and cache versions by tool path and Java options. Keep JDK bounds and diagnostics unchanged.
Keep using
OS.IsWindows. Fix the sharedOSinitializer by deferringProgramFilesX86discovery until its first use, then caching the value. Reading the OS flags no longer queries special folders.Local validation used a source-built Debug SDK with .NET 11 RC2 and JDK 21. Temporary SDK pins and the local-only adb teardown safety change were restored.
build.cmd Prepare— passed.dotnet-local.cmd build Microsoft.Android.slnx -t:BuildDotNet -c Debug -m:4 -nr:false -v:minimal -clp:Summary— passed before the helper revisions; existing warnings, no errors.dotnet-local.cmd build src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj --no-restore -p:BuildProjectReferences=false -nr:false -v:minimal— passed after the OS fix; no warnings or errors.dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj --no-restore -p:BuildProjectReferences=false -nr:false -v:minimal— passed after the OS fix, including the official analyzer; one existing duplicate-source warning.dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj --no-restore -p:BuildProjectReferences=false -nr:false -v:minimal— passed; no warnings or errors.dotnet-local.cmd test bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~ValidateJavaVersionTests|FullyQualifiedName~ResolveSdksTaskTests|FullyQualifiedName~MonoAndroidHelperTests"— 67 passed after the OS fix.dotnet-local.cmd test tests\Xamarin.Android.Tools.AndroidSdk-Tests\Xamarin.Android.Tools.AndroidSdk-Tests.csproj --no-restore -p:BuildProjectReferences=false --filter FullyQualifiedName~AndroidSdkInfoTests -nr:false -v:minimal— 21 passed, 2 skipped.dotnet-local.cmd test tests\Microsoft.Android.Build.BaseTasks-Tests\Microsoft.Android.Build.BaseTasks-Tests.csproj --filter FullyQualifiedName~MultithreadedAndroidTaskTests -v:minimal -nr:false— 7 passed, including file-lock diagnostics.ProgramFilesX86uninitialized; first access returns the expected Windows folder and caches it.java/javacexecution, and cache reuse in ordinary mode and with-m -mt -nr:false -warnaserror:MSB4286,MSB4287,MSB4288— passed with no warnings or errors. The strict probe was repeated after the OS fix.binlogtoolconfirmed strict MT execution with no external task-host messages.