Move OpenJDK installation from xaprepare to MSBuild NoTargets project - #11348

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project
May 20, 2026
Merged

Move OpenJDK installation from xaprepare to MSBuild NoTargets project#11348
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Migrates the JDK download/install from the xaprepare bootstrapper (Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets project, modeled after src/binutils.

New src/openjdk project

  • Downloads the Microsoft OpenJDK archive (platform-specific)
  • Downloads and verifies hash of all downloads
  • Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
  • Supports incremental builds via MSBuild Inputs/Outputs
  • Validates root directory and key JDK files after install
  • Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
  • Handles macOS Contents/Home subdirectory structure

ProjectReferences

Projects that depend on the JDK now have a ProjectReference to src/openjdk, ensuring correct build ordering:

  • src/manifestmerger (gradle + JAVA_HOME)
  • src/r8 (gradle + JAVA_HOME)
  • src/proguard-android (gradle + JAVA_HOME)
  • src/bundletool (uses jar to extract/repack)
  • src/java-runtime (uses javac, jar, java)

Cleanup

  • Deletes all 5 Step_InstallAdoptOpenJDK*.cs files
  • Removes unused constants from all Configurables partial files
  • Removes JI_JAVA_HOME usage (redundant alias for JAVA_HOME set in CI)
  • Removes xaprepare scenario steps that installed OpenJDK

jonathanpeppersand others added 2 commits May 14, 2026 09:04
Migrate the JDK download/install from the xaprepare bootstrapper
(Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets
project, modeled after src/binutils.
The new project:
- Downloads the Microsoft OpenJDK archive (platform-specific)
- Downloads and verifies hash of all downloads
- Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
- Supports incremental builds via MSBuild Inputs/Outputs
- Validates root directory and key JDK files after install
- Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
- Handles macOS Contents/Home subdirectory structure
Projects that depend on the JDK now have a ProjectReference to
src/openjdk, ensuring correct build ordering:
- src/manifestmerger (gradle + JAVA_HOME)
- src/r8 (gradle + JAVA_HOME)
- src/proguard-android (gradle + JAVA_HOME)
- src/bundletool (uses jar to extract/repack)
- src/java-runtime (uses javac, jar, java)
Also removes all JI_JAVA_HOME usage, which was a redundant alias for
JAVA_HOME set in CI pipelines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts project
Create a new src/androidsdk MSBuild NoTargets project that runs
sdkmanager --licenses with JAVA_HOME set correctly. This project
depends on src/openjdk via ProjectReference, ensuring the JDK is
installed before sdkmanager runs.
The gradle/JDK-dependent projects now reference androidsdk instead
of openjdk directly, since androidsdk transitively depends on openjdk.
Remove the AcceptLicenses method from xaprepare Step_Android_SDK_NDK,
which was failing in CI because it ran before the JDK was installed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 0381336 to e1571c5CompareMay 14, 2026 16:12
jonathanpeppersand others added 4 commits May 14, 2026 13:22
Test projects that import TestApks.targets call sdkmanager with
JAVA_HOME, so they need androidsdk to ensure the JDK is installed
first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rs.targets
Test binding projects that import Jar.targets call javac/jar with
JavaSdkDirectory, and Mono.Android imports JavaCallableWrappers.targets
which runs D8 with JAVA_HOME. Both need the JDK installed first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference in .targets files does not work. Add it directly to
Emulator.csproj which is the project built standalone by the CI
pipeline to start/stop the Android emulator. This ensures the JDK
is installed before sdkmanager is called.
Revert the ineffective .targets changes from the previous commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference from Emulator.csproj to androidsdk is not sufficient
because the project is built standalone by the pipeline and the
reference is not resolved in time. Add an explicit build step in
setup-test-environment-steps.yaml after xaprepare to ensure the JDK
is installed and SDK licenses are accepted before any test project
that needs Java runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 18, 2026 19:24
CopilotAI review requested due to automatic review settings May 18, 2026 19:24
@jonathanpeppers

Copy link
Copy Markdown
MemberAuthor

/review

@github-actions

github-actionsBot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

CopilotAI 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

Migrates Microsoft OpenJDK installation from the xaprepare C# bootstrapper (Step_InstallAdoptOpenJDK*) into a new MSBuild NoTargets project (src/openjdk), modeled after src/binutils. A second new MSBuild project (src/androidsdk) takes over Android SDK license acceptance (previously AcceptLicenses in Step_Android_SDK_NDK). Projects that need a JDK at build time (manifestmerger, r8, proguard-android, bundletool, java-runtime, and the test Emulator.csproj) gain a ProjectReference to androidsdk/openjdk to enforce build ordering. The JI_JAVA_HOME alias is removed across CI, MSBuild, and test helpers, and dead OpenJDK constants are pruned from all Configurables.* partials.

Changes:

  • Add src/openjdk (download/verify/extract/install Microsoft OpenJDK) and src/androidsdk (accept SDK licenses), wired in via Xamarin.Android.sln and ProjectReferences.
  • Delete Step_InstallAdoptOpenJDK*.cs, Step_Android_SDK_NDK.AcceptLicenses, and unused MicrosoftOpenJDK*/AdoptOpenJDK*/OpenJDKInstallDir/OpenJDKCacheDir definitions; remove the OpenJDK steps from the standard and test scenarios.
  • Drop all JI_JAVA_HOME/JI_JAVA_HOME_DEFAULT usage from setup-jdk-variables.yaml, azure-pipelines-nightly.yaml, OS.InitOS, and AndroidSdkResolver; introduce a CI step that builds androidsdk.csproj to perform the JDK install + license acceptance.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
Xamarin.Android.slnRegisters the new openjdk and androidsdk projects.
Configuration.propsIntroduces MicrosoftOpenJDKVersion/Folder/RootDirName and unconditionally sets JavaSdkDirectory to the install location.
src/openjdk/openjdk.csproj, openjdk.targetsNew NoTargets project that downloads, hash-verifies, extracts, and installs the Microsoft OpenJDK.
src/androidsdk/androidsdk.csproj, androidsdk.targetsNew NoTargets project that runs sdkmanager --licenses to accept Android SDK licenses, taking a ProjectReference on openjdk.
src/manifestmerger/manifestmerger.csproj, src/r8/r8.csproj, src/proguard-android/proguard-android.csproj, src/bundletool/bundletool.csproj, src/java-runtime/java-runtime.csprojAdd ProjectReference to androidsdk so JDK is available before gradle/jar/javac steps.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csprojAdds ProjectReference to androidsdk for test environment.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.csRemoves JI_JAVA_HOME lookup.
build-tools/xaprepare/.../Step_InstallAdoptOpenJDK*.csDeletes all five OpenJDK install step files.
build-tools/xaprepare/.../Step_Android_SDK_NDK.csRemoves AcceptLicenses and its callers (now handled by androidsdk.csproj).
build-tools/xaprepare/.../Scenario_Standard.cs, Scenario_AndroidTestDependencies.cs, Scenario_EmulatorTestDependencies.csDrops Step_InstallMicrosoftOpenJDK and updates descriptions.
build-tools/xaprepare/.../OperatingSystems/OS.csJavaHome no longer falls back to JI_JAVA_HOME.
build-tools/xaprepare/.../ConfigAndData/Configurables*.csRemoves unused OpenJDK constants, URLs, paths, and cached fields.
build-tools/automation/yaml-templates/setup-test-environment-steps.yamlAdds a step that builds androidsdk.csproj to install JDK and accept licenses.
build-tools/automation/yaml-templates/setup-jdk-variables.yamlStops setting JI_JAVA_HOME / JI_JAVA_HOME_DEFAULT.
build-tools/automation/azure-pipelines-nightly.yamlSwitches JavaSdkDirectory arg from $(JI_JAVA_HOME_DEFAULT) to $(JAVA_HOME).

Comment threadsrc/androidsdk/androidsdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/openjdk/openjdk.targets
Comment threadConfiguration.props
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/proguard-android/proguard-android.csproj

@github-actionsgithub-actionsBot 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.

✅ LGTM

Clean, well-structured migration that follows the established binutils pattern. The dependency graph (projects → androidsdkopenjdk) correctly ensures JDK is installed before any Java-dependent build step, and the removal of JI_JAVA_HOME simplifies CI without leaving dangling references.

Positive callouts:

  • SHA-256 hash verification of downloads is a good security improvement over the old code (which only checked version strings)
  • Incremental build support via Inputs/Outputs on all targets is correct
  • The separation of openjdk (download/install JDK) from androidsdk (accept licenses) is a clean abstraction
  • CI yaml cleanup (removing JI_JAVA_HOME, JI_JAVA_HOME_DEFAULT) is thorough

Issues: 0 ❌ | 0 ⚠️ | 2 💡

Generated by Android PR Reviewer for issue #11348 · ● 12.6M

Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 98a580f to 59f1c2aCompareMay 18, 2026 19:41
Fix 1: PowerShell "y" * 10 produces one string "yyyyyyyyyy", not 10
separate lines. Use 1..10 | ForEach-Object { "y" } instead.
Fix 2: Simplify JDK installation to a single tar call that extracts
directly into the install directory using --strip-components to flatten
the archive root folder. Windows 10+ includes bsdtar which handles
both .zip and .tar.gz. On macOS, strip 3 levels (jdk-X/Contents/Home)
vs 1 level (jdk-X) on Windows/Linux.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 59f1c2a to 3eaa5dfCompareMay 18, 2026 19:43
The macOS tar.gz has ./jdk-21.0.8+9/Contents/Home/bin/javac (4 levels)
while Windows/Linux have jdk-21.0.8+9/bin/javac (1 level). The leading
./ is counted by --strip-components, so macOS needs 4 not 3.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@simonrozsival
simonrozsival merged commit 0be3e63 into mainMay 20, 2026
3 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers/openjdk-msbuild-project branch May 20, 2026 21:01
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jun 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis 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.

3 participants

@jonathanpeppers@simonrozsival
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Move OpenJDK installation from xaprepare to MSBuild NoTargets project - #11348

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project
May 20, 2026
Merged

Move OpenJDK installation from xaprepare to MSBuild NoTargets project#11348
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Migrates the JDK download/install from the xaprepare bootstrapper (Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets project, modeled after src/binutils.

New src/openjdk project

  • Downloads the Microsoft OpenJDK archive (platform-specific)
  • Downloads and verifies hash of all downloads
  • Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
  • Supports incremental builds via MSBuild Inputs/Outputs
  • Validates root directory and key JDK files after install
  • Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
  • Handles macOS Contents/Home subdirectory structure

ProjectReferences

Projects that depend on the JDK now have a ProjectReference to src/openjdk, ensuring correct build ordering:

  • src/manifestmerger (gradle + JAVA_HOME)
  • src/r8 (gradle + JAVA_HOME)
  • src/proguard-android (gradle + JAVA_HOME)
  • src/bundletool (uses jar to extract/repack)
  • src/java-runtime (uses javac, jar, java)

Cleanup

  • Deletes all 5 Step_InstallAdoptOpenJDK*.cs files
  • Removes unused constants from all Configurables partial files
  • Removes JI_JAVA_HOME usage (redundant alias for JAVA_HOME set in CI)
  • Removes xaprepare scenario steps that installed OpenJDK

jonathanpeppersand others added 2 commits May 14, 2026 09:04
Migrate the JDK download/install from the xaprepare bootstrapper
(Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets
project, modeled after src/binutils.
The new project:
- Downloads the Microsoft OpenJDK archive (platform-specific)
- Downloads and verifies hash of all downloads
- Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
- Supports incremental builds via MSBuild Inputs/Outputs
- Validates root directory and key JDK files after install
- Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
- Handles macOS Contents/Home subdirectory structure
Projects that depend on the JDK now have a ProjectReference to
src/openjdk, ensuring correct build ordering:
- src/manifestmerger (gradle + JAVA_HOME)
- src/r8 (gradle + JAVA_HOME)
- src/proguard-android (gradle + JAVA_HOME)
- src/bundletool (uses jar to extract/repack)
- src/java-runtime (uses javac, jar, java)
Also removes all JI_JAVA_HOME usage, which was a redundant alias for
JAVA_HOME set in CI pipelines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts project
Create a new src/androidsdk MSBuild NoTargets project that runs
sdkmanager --licenses with JAVA_HOME set correctly. This project
depends on src/openjdk via ProjectReference, ensuring the JDK is
installed before sdkmanager runs.
The gradle/JDK-dependent projects now reference androidsdk instead
of openjdk directly, since androidsdk transitively depends on openjdk.
Remove the AcceptLicenses method from xaprepare Step_Android_SDK_NDK,
which was failing in CI because it ran before the JDK was installed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 0381336 to e1571c5CompareMay 14, 2026 16:12
jonathanpeppersand others added 4 commits May 14, 2026 13:22
Test projects that import TestApks.targets call sdkmanager with
JAVA_HOME, so they need androidsdk to ensure the JDK is installed
first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rs.targets
Test binding projects that import Jar.targets call javac/jar with
JavaSdkDirectory, and Mono.Android imports JavaCallableWrappers.targets
which runs D8 with JAVA_HOME. Both need the JDK installed first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference in .targets files does not work. Add it directly to
Emulator.csproj which is the project built standalone by the CI
pipeline to start/stop the Android emulator. This ensures the JDK
is installed before sdkmanager is called.
Revert the ineffective .targets changes from the previous commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference from Emulator.csproj to androidsdk is not sufficient
because the project is built standalone by the pipeline and the
reference is not resolved in time. Add an explicit build step in
setup-test-environment-steps.yaml after xaprepare to ensure the JDK
is installed and SDK licenses are accepted before any test project
that needs Java runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 18, 2026 19:24
CopilotAI review requested due to automatic review settings May 18, 2026 19:24
@jonathanpeppers

Copy link
Copy Markdown
MemberAuthor

/review

@github-actions

github-actionsBot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

CopilotAI 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

Migrates Microsoft OpenJDK installation from the xaprepare C# bootstrapper (Step_InstallAdoptOpenJDK*) into a new MSBuild NoTargets project (src/openjdk), modeled after src/binutils. A second new MSBuild project (src/androidsdk) takes over Android SDK license acceptance (previously AcceptLicenses in Step_Android_SDK_NDK). Projects that need a JDK at build time (manifestmerger, r8, proguard-android, bundletool, java-runtime, and the test Emulator.csproj) gain a ProjectReference to androidsdk/openjdk to enforce build ordering. The JI_JAVA_HOME alias is removed across CI, MSBuild, and test helpers, and dead OpenJDK constants are pruned from all Configurables.* partials.

Changes:

  • Add src/openjdk (download/verify/extract/install Microsoft OpenJDK) and src/androidsdk (accept SDK licenses), wired in via Xamarin.Android.sln and ProjectReferences.
  • Delete Step_InstallAdoptOpenJDK*.cs, Step_Android_SDK_NDK.AcceptLicenses, and unused MicrosoftOpenJDK*/AdoptOpenJDK*/OpenJDKInstallDir/OpenJDKCacheDir definitions; remove the OpenJDK steps from the standard and test scenarios.
  • Drop all JI_JAVA_HOME/JI_JAVA_HOME_DEFAULT usage from setup-jdk-variables.yaml, azure-pipelines-nightly.yaml, OS.InitOS, and AndroidSdkResolver; introduce a CI step that builds androidsdk.csproj to perform the JDK install + license acceptance.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
Xamarin.Android.slnRegisters the new openjdk and androidsdk projects.
Configuration.propsIntroduces MicrosoftOpenJDKVersion/Folder/RootDirName and unconditionally sets JavaSdkDirectory to the install location.
src/openjdk/openjdk.csproj, openjdk.targetsNew NoTargets project that downloads, hash-verifies, extracts, and installs the Microsoft OpenJDK.
src/androidsdk/androidsdk.csproj, androidsdk.targetsNew NoTargets project that runs sdkmanager --licenses to accept Android SDK licenses, taking a ProjectReference on openjdk.
src/manifestmerger/manifestmerger.csproj, src/r8/r8.csproj, src/proguard-android/proguard-android.csproj, src/bundletool/bundletool.csproj, src/java-runtime/java-runtime.csprojAdd ProjectReference to androidsdk so JDK is available before gradle/jar/javac steps.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csprojAdds ProjectReference to androidsdk for test environment.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.csRemoves JI_JAVA_HOME lookup.
build-tools/xaprepare/.../Step_InstallAdoptOpenJDK*.csDeletes all five OpenJDK install step files.
build-tools/xaprepare/.../Step_Android_SDK_NDK.csRemoves AcceptLicenses and its callers (now handled by androidsdk.csproj).
build-tools/xaprepare/.../Scenario_Standard.cs, Scenario_AndroidTestDependencies.cs, Scenario_EmulatorTestDependencies.csDrops Step_InstallMicrosoftOpenJDK and updates descriptions.
build-tools/xaprepare/.../OperatingSystems/OS.csJavaHome no longer falls back to JI_JAVA_HOME.
build-tools/xaprepare/.../ConfigAndData/Configurables*.csRemoves unused OpenJDK constants, URLs, paths, and cached fields.
build-tools/automation/yaml-templates/setup-test-environment-steps.yamlAdds a step that builds androidsdk.csproj to install JDK and accept licenses.
build-tools/automation/yaml-templates/setup-jdk-variables.yamlStops setting JI_JAVA_HOME / JI_JAVA_HOME_DEFAULT.
build-tools/automation/azure-pipelines-nightly.yamlSwitches JavaSdkDirectory arg from $(JI_JAVA_HOME_DEFAULT) to $(JAVA_HOME).

Comment threadsrc/androidsdk/androidsdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/openjdk/openjdk.targets
Comment threadConfiguration.props
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/proguard-android/proguard-android.csproj

@github-actionsgithub-actionsBot 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.

✅ LGTM

Clean, well-structured migration that follows the established binutils pattern. The dependency graph (projects → androidsdkopenjdk) correctly ensures JDK is installed before any Java-dependent build step, and the removal of JI_JAVA_HOME simplifies CI without leaving dangling references.

Positive callouts:

  • SHA-256 hash verification of downloads is a good security improvement over the old code (which only checked version strings)
  • Incremental build support via Inputs/Outputs on all targets is correct
  • The separation of openjdk (download/install JDK) from androidsdk (accept licenses) is a clean abstraction
  • CI yaml cleanup (removing JI_JAVA_HOME, JI_JAVA_HOME_DEFAULT) is thorough

Issues: 0 ❌ | 0 ⚠️ | 2 💡

Generated by Android PR Reviewer for issue #11348 · ● 12.6M

Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 98a580f to 59f1c2aCompareMay 18, 2026 19:41
Fix 1: PowerShell "y" * 10 produces one string "yyyyyyyyyy", not 10
separate lines. Use 1..10 | ForEach-Object { "y" } instead.
Fix 2: Simplify JDK installation to a single tar call that extracts
directly into the install directory using --strip-components to flatten
the archive root folder. Windows 10+ includes bsdtar which handles
both .zip and .tar.gz. On macOS, strip 3 levels (jdk-X/Contents/Home)
vs 1 level (jdk-X) on Windows/Linux.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 59f1c2a to 3eaa5dfCompareMay 18, 2026 19:43
The macOS tar.gz has ./jdk-21.0.8+9/Contents/Home/bin/javac (4 levels)
while Windows/Linux have jdk-21.0.8+9/bin/javac (1 level). The leading
./ is counted by --strip-components, so macOS needs 4 not 3.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@simonrozsival
simonrozsival merged commit 0be3e63 into mainMay 20, 2026
3 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers/openjdk-msbuild-project branch May 20, 2026 21:01
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jun 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis 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.

3 participants

@jonathanpeppers@simonrozsival
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Move OpenJDK installation from xaprepare to MSBuild NoTargets project - #11348

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project
May 20, 2026
Merged

Move OpenJDK installation from xaprepare to MSBuild NoTargets project#11348
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Migrates the JDK download/install from the xaprepare bootstrapper (Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets project, modeled after src/binutils.

New src/openjdk project

  • Downloads the Microsoft OpenJDK archive (platform-specific)
  • Downloads and verifies hash of all downloads
  • Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
  • Supports incremental builds via MSBuild Inputs/Outputs
  • Validates root directory and key JDK files after install
  • Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
  • Handles macOS Contents/Home subdirectory structure

ProjectReferences

Projects that depend on the JDK now have a ProjectReference to src/openjdk, ensuring correct build ordering:

  • src/manifestmerger (gradle + JAVA_HOME)
  • src/r8 (gradle + JAVA_HOME)
  • src/proguard-android (gradle + JAVA_HOME)
  • src/bundletool (uses jar to extract/repack)
  • src/java-runtime (uses javac, jar, java)

Cleanup

  • Deletes all 5 Step_InstallAdoptOpenJDK*.cs files
  • Removes unused constants from all Configurables partial files
  • Removes JI_JAVA_HOME usage (redundant alias for JAVA_HOME set in CI)
  • Removes xaprepare scenario steps that installed OpenJDK

jonathanpeppersand others added 2 commits May 14, 2026 09:04
Migrate the JDK download/install from the xaprepare bootstrapper
(Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets
project, modeled after src/binutils.
The new project:
- Downloads the Microsoft OpenJDK archive (platform-specific)
- Downloads and verifies hash of all downloads
- Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
- Supports incremental builds via MSBuild Inputs/Outputs
- Validates root directory and key JDK files after install
- Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
- Handles macOS Contents/Home subdirectory structure
Projects that depend on the JDK now have a ProjectReference to
src/openjdk, ensuring correct build ordering:
- src/manifestmerger (gradle + JAVA_HOME)
- src/r8 (gradle + JAVA_HOME)
- src/proguard-android (gradle + JAVA_HOME)
- src/bundletool (uses jar to extract/repack)
- src/java-runtime (uses javac, jar, java)
Also removes all JI_JAVA_HOME usage, which was a redundant alias for
JAVA_HOME set in CI pipelines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts project
Create a new src/androidsdk MSBuild NoTargets project that runs
sdkmanager --licenses with JAVA_HOME set correctly. This project
depends on src/openjdk via ProjectReference, ensuring the JDK is
installed before sdkmanager runs.
The gradle/JDK-dependent projects now reference androidsdk instead
of openjdk directly, since androidsdk transitively depends on openjdk.
Remove the AcceptLicenses method from xaprepare Step_Android_SDK_NDK,
which was failing in CI because it ran before the JDK was installed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 0381336 to e1571c5CompareMay 14, 2026 16:12
jonathanpeppersand others added 4 commits May 14, 2026 13:22
Test projects that import TestApks.targets call sdkmanager with
JAVA_HOME, so they need androidsdk to ensure the JDK is installed
first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rs.targets
Test binding projects that import Jar.targets call javac/jar with
JavaSdkDirectory, and Mono.Android imports JavaCallableWrappers.targets
which runs D8 with JAVA_HOME. Both need the JDK installed first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference in .targets files does not work. Add it directly to
Emulator.csproj which is the project built standalone by the CI
pipeline to start/stop the Android emulator. This ensures the JDK
is installed before sdkmanager is called.
Revert the ineffective .targets changes from the previous commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference from Emulator.csproj to androidsdk is not sufficient
because the project is built standalone by the pipeline and the
reference is not resolved in time. Add an explicit build step in
setup-test-environment-steps.yaml after xaprepare to ensure the JDK
is installed and SDK licenses are accepted before any test project
that needs Java runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 18, 2026 19:24
CopilotAI review requested due to automatic review settings May 18, 2026 19:24
@jonathanpeppers

Copy link
Copy Markdown
MemberAuthor

/review

@github-actions

github-actionsBot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

CopilotAI 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

Migrates Microsoft OpenJDK installation from the xaprepare C# bootstrapper (Step_InstallAdoptOpenJDK*) into a new MSBuild NoTargets project (src/openjdk), modeled after src/binutils. A second new MSBuild project (src/androidsdk) takes over Android SDK license acceptance (previously AcceptLicenses in Step_Android_SDK_NDK). Projects that need a JDK at build time (manifestmerger, r8, proguard-android, bundletool, java-runtime, and the test Emulator.csproj) gain a ProjectReference to androidsdk/openjdk to enforce build ordering. The JI_JAVA_HOME alias is removed across CI, MSBuild, and test helpers, and dead OpenJDK constants are pruned from all Configurables.* partials.

Changes:

  • Add src/openjdk (download/verify/extract/install Microsoft OpenJDK) and src/androidsdk (accept SDK licenses), wired in via Xamarin.Android.sln and ProjectReferences.
  • Delete Step_InstallAdoptOpenJDK*.cs, Step_Android_SDK_NDK.AcceptLicenses, and unused MicrosoftOpenJDK*/AdoptOpenJDK*/OpenJDKInstallDir/OpenJDKCacheDir definitions; remove the OpenJDK steps from the standard and test scenarios.
  • Drop all JI_JAVA_HOME/JI_JAVA_HOME_DEFAULT usage from setup-jdk-variables.yaml, azure-pipelines-nightly.yaml, OS.InitOS, and AndroidSdkResolver; introduce a CI step that builds androidsdk.csproj to perform the JDK install + license acceptance.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
Xamarin.Android.slnRegisters the new openjdk and androidsdk projects.
Configuration.propsIntroduces MicrosoftOpenJDKVersion/Folder/RootDirName and unconditionally sets JavaSdkDirectory to the install location.
src/openjdk/openjdk.csproj, openjdk.targetsNew NoTargets project that downloads, hash-verifies, extracts, and installs the Microsoft OpenJDK.
src/androidsdk/androidsdk.csproj, androidsdk.targetsNew NoTargets project that runs sdkmanager --licenses to accept Android SDK licenses, taking a ProjectReference on openjdk.
src/manifestmerger/manifestmerger.csproj, src/r8/r8.csproj, src/proguard-android/proguard-android.csproj, src/bundletool/bundletool.csproj, src/java-runtime/java-runtime.csprojAdd ProjectReference to androidsdk so JDK is available before gradle/jar/javac steps.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csprojAdds ProjectReference to androidsdk for test environment.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.csRemoves JI_JAVA_HOME lookup.
build-tools/xaprepare/.../Step_InstallAdoptOpenJDK*.csDeletes all five OpenJDK install step files.
build-tools/xaprepare/.../Step_Android_SDK_NDK.csRemoves AcceptLicenses and its callers (now handled by androidsdk.csproj).
build-tools/xaprepare/.../Scenario_Standard.cs, Scenario_AndroidTestDependencies.cs, Scenario_EmulatorTestDependencies.csDrops Step_InstallMicrosoftOpenJDK and updates descriptions.
build-tools/xaprepare/.../OperatingSystems/OS.csJavaHome no longer falls back to JI_JAVA_HOME.
build-tools/xaprepare/.../ConfigAndData/Configurables*.csRemoves unused OpenJDK constants, URLs, paths, and cached fields.
build-tools/automation/yaml-templates/setup-test-environment-steps.yamlAdds a step that builds androidsdk.csproj to install JDK and accept licenses.
build-tools/automation/yaml-templates/setup-jdk-variables.yamlStops setting JI_JAVA_HOME / JI_JAVA_HOME_DEFAULT.
build-tools/automation/azure-pipelines-nightly.yamlSwitches JavaSdkDirectory arg from $(JI_JAVA_HOME_DEFAULT) to $(JAVA_HOME).

Comment threadsrc/androidsdk/androidsdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/openjdk/openjdk.targets
Comment threadConfiguration.props
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/proguard-android/proguard-android.csproj

@github-actionsgithub-actionsBot 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.

✅ LGTM

Clean, well-structured migration that follows the established binutils pattern. The dependency graph (projects → androidsdkopenjdk) correctly ensures JDK is installed before any Java-dependent build step, and the removal of JI_JAVA_HOME simplifies CI without leaving dangling references.

Positive callouts:

  • SHA-256 hash verification of downloads is a good security improvement over the old code (which only checked version strings)
  • Incremental build support via Inputs/Outputs on all targets is correct
  • The separation of openjdk (download/install JDK) from androidsdk (accept licenses) is a clean abstraction
  • CI yaml cleanup (removing JI_JAVA_HOME, JI_JAVA_HOME_DEFAULT) is thorough

Issues: 0 ❌ | 0 ⚠️ | 2 💡

Generated by Android PR Reviewer for issue #11348 · ● 12.6M

Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 98a580f to 59f1c2aCompareMay 18, 2026 19:41
Fix 1: PowerShell "y" * 10 produces one string "yyyyyyyyyy", not 10
separate lines. Use 1..10 | ForEach-Object { "y" } instead.
Fix 2: Simplify JDK installation to a single tar call that extracts
directly into the install directory using --strip-components to flatten
the archive root folder. Windows 10+ includes bsdtar which handles
both .zip and .tar.gz. On macOS, strip 3 levels (jdk-X/Contents/Home)
vs 1 level (jdk-X) on Windows/Linux.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 59f1c2a to 3eaa5dfCompareMay 18, 2026 19:43
The macOS tar.gz has ./jdk-21.0.8+9/Contents/Home/bin/javac (4 levels)
while Windows/Linux have jdk-21.0.8+9/bin/javac (1 level). The leading
./ is counted by --strip-components, so macOS needs 4 not 3.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@simonrozsival
simonrozsival merged commit 0be3e63 into mainMay 20, 2026
3 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers/openjdk-msbuild-project branch May 20, 2026 21:01
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jun 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis 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.

3 participants

@jonathanpeppers@simonrozsival
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Move OpenJDK installation from xaprepare to MSBuild NoTargets project - #11348

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project
May 20, 2026
Merged

Move OpenJDK installation from xaprepare to MSBuild NoTargets project#11348
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Migrates the JDK download/install from the xaprepare bootstrapper (Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets project, modeled after src/binutils.

New src/openjdk project

  • Downloads the Microsoft OpenJDK archive (platform-specific)
  • Downloads and verifies hash of all downloads
  • Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
  • Supports incremental builds via MSBuild Inputs/Outputs
  • Validates root directory and key JDK files after install
  • Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
  • Handles macOS Contents/Home subdirectory structure

ProjectReferences

Projects that depend on the JDK now have a ProjectReference to src/openjdk, ensuring correct build ordering:

  • src/manifestmerger (gradle + JAVA_HOME)
  • src/r8 (gradle + JAVA_HOME)
  • src/proguard-android (gradle + JAVA_HOME)
  • src/bundletool (uses jar to extract/repack)
  • src/java-runtime (uses javac, jar, java)

Cleanup

  • Deletes all 5 Step_InstallAdoptOpenJDK*.cs files
  • Removes unused constants from all Configurables partial files
  • Removes JI_JAVA_HOME usage (redundant alias for JAVA_HOME set in CI)
  • Removes xaprepare scenario steps that installed OpenJDK

jonathanpeppersand others added 2 commits May 14, 2026 09:04
Migrate the JDK download/install from the xaprepare bootstrapper
(Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets
project, modeled after src/binutils.
The new project:
- Downloads the Microsoft OpenJDK archive (platform-specific)
- Downloads and verifies hash of all downloads
- Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
- Supports incremental builds via MSBuild Inputs/Outputs
- Validates root directory and key JDK files after install
- Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
- Handles macOS Contents/Home subdirectory structure
Projects that depend on the JDK now have a ProjectReference to
src/openjdk, ensuring correct build ordering:
- src/manifestmerger (gradle + JAVA_HOME)
- src/r8 (gradle + JAVA_HOME)
- src/proguard-android (gradle + JAVA_HOME)
- src/bundletool (uses jar to extract/repack)
- src/java-runtime (uses javac, jar, java)
Also removes all JI_JAVA_HOME usage, which was a redundant alias for
JAVA_HOME set in CI pipelines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts project
Create a new src/androidsdk MSBuild NoTargets project that runs
sdkmanager --licenses with JAVA_HOME set correctly. This project
depends on src/openjdk via ProjectReference, ensuring the JDK is
installed before sdkmanager runs.
The gradle/JDK-dependent projects now reference androidsdk instead
of openjdk directly, since androidsdk transitively depends on openjdk.
Remove the AcceptLicenses method from xaprepare Step_Android_SDK_NDK,
which was failing in CI because it ran before the JDK was installed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 0381336 to e1571c5CompareMay 14, 2026 16:12
jonathanpeppersand others added 4 commits May 14, 2026 13:22
Test projects that import TestApks.targets call sdkmanager with
JAVA_HOME, so they need androidsdk to ensure the JDK is installed
first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rs.targets
Test binding projects that import Jar.targets call javac/jar with
JavaSdkDirectory, and Mono.Android imports JavaCallableWrappers.targets
which runs D8 with JAVA_HOME. Both need the JDK installed first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference in .targets files does not work. Add it directly to
Emulator.csproj which is the project built standalone by the CI
pipeline to start/stop the Android emulator. This ensures the JDK
is installed before sdkmanager is called.
Revert the ineffective .targets changes from the previous commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference from Emulator.csproj to androidsdk is not sufficient
because the project is built standalone by the pipeline and the
reference is not resolved in time. Add an explicit build step in
setup-test-environment-steps.yaml after xaprepare to ensure the JDK
is installed and SDK licenses are accepted before any test project
that needs Java runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 18, 2026 19:24
CopilotAI review requested due to automatic review settings May 18, 2026 19:24
@jonathanpeppers

Copy link
Copy Markdown
MemberAuthor

/review

@github-actions

github-actionsBot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

CopilotAI 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

Migrates Microsoft OpenJDK installation from the xaprepare C# bootstrapper (Step_InstallAdoptOpenJDK*) into a new MSBuild NoTargets project (src/openjdk), modeled after src/binutils. A second new MSBuild project (src/androidsdk) takes over Android SDK license acceptance (previously AcceptLicenses in Step_Android_SDK_NDK). Projects that need a JDK at build time (manifestmerger, r8, proguard-android, bundletool, java-runtime, and the test Emulator.csproj) gain a ProjectReference to androidsdk/openjdk to enforce build ordering. The JI_JAVA_HOME alias is removed across CI, MSBuild, and test helpers, and dead OpenJDK constants are pruned from all Configurables.* partials.

Changes:

  • Add src/openjdk (download/verify/extract/install Microsoft OpenJDK) and src/androidsdk (accept SDK licenses), wired in via Xamarin.Android.sln and ProjectReferences.
  • Delete Step_InstallAdoptOpenJDK*.cs, Step_Android_SDK_NDK.AcceptLicenses, and unused MicrosoftOpenJDK*/AdoptOpenJDK*/OpenJDKInstallDir/OpenJDKCacheDir definitions; remove the OpenJDK steps from the standard and test scenarios.
  • Drop all JI_JAVA_HOME/JI_JAVA_HOME_DEFAULT usage from setup-jdk-variables.yaml, azure-pipelines-nightly.yaml, OS.InitOS, and AndroidSdkResolver; introduce a CI step that builds androidsdk.csproj to perform the JDK install + license acceptance.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
Xamarin.Android.slnRegisters the new openjdk and androidsdk projects.
Configuration.propsIntroduces MicrosoftOpenJDKVersion/Folder/RootDirName and unconditionally sets JavaSdkDirectory to the install location.
src/openjdk/openjdk.csproj, openjdk.targetsNew NoTargets project that downloads, hash-verifies, extracts, and installs the Microsoft OpenJDK.
src/androidsdk/androidsdk.csproj, androidsdk.targetsNew NoTargets project that runs sdkmanager --licenses to accept Android SDK licenses, taking a ProjectReference on openjdk.
src/manifestmerger/manifestmerger.csproj, src/r8/r8.csproj, src/proguard-android/proguard-android.csproj, src/bundletool/bundletool.csproj, src/java-runtime/java-runtime.csprojAdd ProjectReference to androidsdk so JDK is available before gradle/jar/javac steps.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csprojAdds ProjectReference to androidsdk for test environment.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.csRemoves JI_JAVA_HOME lookup.
build-tools/xaprepare/.../Step_InstallAdoptOpenJDK*.csDeletes all five OpenJDK install step files.
build-tools/xaprepare/.../Step_Android_SDK_NDK.csRemoves AcceptLicenses and its callers (now handled by androidsdk.csproj).
build-tools/xaprepare/.../Scenario_Standard.cs, Scenario_AndroidTestDependencies.cs, Scenario_EmulatorTestDependencies.csDrops Step_InstallMicrosoftOpenJDK and updates descriptions.
build-tools/xaprepare/.../OperatingSystems/OS.csJavaHome no longer falls back to JI_JAVA_HOME.
build-tools/xaprepare/.../ConfigAndData/Configurables*.csRemoves unused OpenJDK constants, URLs, paths, and cached fields.
build-tools/automation/yaml-templates/setup-test-environment-steps.yamlAdds a step that builds androidsdk.csproj to install JDK and accept licenses.
build-tools/automation/yaml-templates/setup-jdk-variables.yamlStops setting JI_JAVA_HOME / JI_JAVA_HOME_DEFAULT.
build-tools/automation/azure-pipelines-nightly.yamlSwitches JavaSdkDirectory arg from $(JI_JAVA_HOME_DEFAULT) to $(JAVA_HOME).

Comment threadsrc/androidsdk/androidsdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/openjdk/openjdk.targets
Comment threadConfiguration.props
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/proguard-android/proguard-android.csproj

@github-actionsgithub-actionsBot 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.

✅ LGTM

Clean, well-structured migration that follows the established binutils pattern. The dependency graph (projects → androidsdkopenjdk) correctly ensures JDK is installed before any Java-dependent build step, and the removal of JI_JAVA_HOME simplifies CI without leaving dangling references.

Positive callouts:

  • SHA-256 hash verification of downloads is a good security improvement over the old code (which only checked version strings)
  • Incremental build support via Inputs/Outputs on all targets is correct
  • The separation of openjdk (download/install JDK) from androidsdk (accept licenses) is a clean abstraction
  • CI yaml cleanup (removing JI_JAVA_HOME, JI_JAVA_HOME_DEFAULT) is thorough

Issues: 0 ❌ | 0 ⚠️ | 2 💡

Generated by Android PR Reviewer for issue #11348 · ● 12.6M

Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 98a580f to 59f1c2aCompareMay 18, 2026 19:41
Fix 1: PowerShell "y" * 10 produces one string "yyyyyyyyyy", not 10
separate lines. Use 1..10 | ForEach-Object { "y" } instead.
Fix 2: Simplify JDK installation to a single tar call that extracts
directly into the install directory using --strip-components to flatten
the archive root folder. Windows 10+ includes bsdtar which handles
both .zip and .tar.gz. On macOS, strip 3 levels (jdk-X/Contents/Home)
vs 1 level (jdk-X) on Windows/Linux.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 59f1c2a to 3eaa5dfCompareMay 18, 2026 19:43
The macOS tar.gz has ./jdk-21.0.8+9/Contents/Home/bin/javac (4 levels)
while Windows/Linux have jdk-21.0.8+9/bin/javac (1 level). The leading
./ is counted by --strip-components, so macOS needs 4 not 3.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@simonrozsival
simonrozsival merged commit 0be3e63 into mainMay 20, 2026
3 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers/openjdk-msbuild-project branch May 20, 2026 21:01
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jun 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis 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.

3 participants

@jonathanpeppers@simonrozsival
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Move OpenJDK installation from xaprepare to MSBuild NoTargets project - #11348

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project
May 20, 2026
Merged

Move OpenJDK installation from xaprepare to MSBuild NoTargets project#11348
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Migrates the JDK download/install from the xaprepare bootstrapper (Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets project, modeled after src/binutils.

New src/openjdk project

  • Downloads the Microsoft OpenJDK archive (platform-specific)
  • Downloads and verifies hash of all downloads
  • Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
  • Supports incremental builds via MSBuild Inputs/Outputs
  • Validates root directory and key JDK files after install
  • Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
  • Handles macOS Contents/Home subdirectory structure

ProjectReferences

Projects that depend on the JDK now have a ProjectReference to src/openjdk, ensuring correct build ordering:

  • src/manifestmerger (gradle + JAVA_HOME)
  • src/r8 (gradle + JAVA_HOME)
  • src/proguard-android (gradle + JAVA_HOME)
  • src/bundletool (uses jar to extract/repack)
  • src/java-runtime (uses javac, jar, java)

Cleanup

  • Deletes all 5 Step_InstallAdoptOpenJDK*.cs files
  • Removes unused constants from all Configurables partial files
  • Removes JI_JAVA_HOME usage (redundant alias for JAVA_HOME set in CI)
  • Removes xaprepare scenario steps that installed OpenJDK

jonathanpeppersand others added 2 commits May 14, 2026 09:04
Migrate the JDK download/install from the xaprepare bootstrapper
(Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets
project, modeled after src/binutils.
The new project:
- Downloads the Microsoft OpenJDK archive (platform-specific)
- Downloads and verifies hash of all downloads
- Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
- Supports incremental builds via MSBuild Inputs/Outputs
- Validates root directory and key JDK files after install
- Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
- Handles macOS Contents/Home subdirectory structure
Projects that depend on the JDK now have a ProjectReference to
src/openjdk, ensuring correct build ordering:
- src/manifestmerger (gradle + JAVA_HOME)
- src/r8 (gradle + JAVA_HOME)
- src/proguard-android (gradle + JAVA_HOME)
- src/bundletool (uses jar to extract/repack)
- src/java-runtime (uses javac, jar, java)
Also removes all JI_JAVA_HOME usage, which was a redundant alias for
JAVA_HOME set in CI pipelines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts project
Create a new src/androidsdk MSBuild NoTargets project that runs
sdkmanager --licenses with JAVA_HOME set correctly. This project
depends on src/openjdk via ProjectReference, ensuring the JDK is
installed before sdkmanager runs.
The gradle/JDK-dependent projects now reference androidsdk instead
of openjdk directly, since androidsdk transitively depends on openjdk.
Remove the AcceptLicenses method from xaprepare Step_Android_SDK_NDK,
which was failing in CI because it ran before the JDK was installed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 0381336 to e1571c5CompareMay 14, 2026 16:12
jonathanpeppersand others added 4 commits May 14, 2026 13:22
Test projects that import TestApks.targets call sdkmanager with
JAVA_HOME, so they need androidsdk to ensure the JDK is installed
first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rs.targets
Test binding projects that import Jar.targets call javac/jar with
JavaSdkDirectory, and Mono.Android imports JavaCallableWrappers.targets
which runs D8 with JAVA_HOME. Both need the JDK installed first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference in .targets files does not work. Add it directly to
Emulator.csproj which is the project built standalone by the CI
pipeline to start/stop the Android emulator. This ensures the JDK
is installed before sdkmanager is called.
Revert the ineffective .targets changes from the previous commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference from Emulator.csproj to androidsdk is not sufficient
because the project is built standalone by the pipeline and the
reference is not resolved in time. Add an explicit build step in
setup-test-environment-steps.yaml after xaprepare to ensure the JDK
is installed and SDK licenses are accepted before any test project
that needs Java runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 18, 2026 19:24
CopilotAI review requested due to automatic review settings May 18, 2026 19:24
@jonathanpeppers

Copy link
Copy Markdown
MemberAuthor

/review

@github-actions

github-actionsBot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

CopilotAI 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

Migrates Microsoft OpenJDK installation from the xaprepare C# bootstrapper (Step_InstallAdoptOpenJDK*) into a new MSBuild NoTargets project (src/openjdk), modeled after src/binutils. A second new MSBuild project (src/androidsdk) takes over Android SDK license acceptance (previously AcceptLicenses in Step_Android_SDK_NDK). Projects that need a JDK at build time (manifestmerger, r8, proguard-android, bundletool, java-runtime, and the test Emulator.csproj) gain a ProjectReference to androidsdk/openjdk to enforce build ordering. The JI_JAVA_HOME alias is removed across CI, MSBuild, and test helpers, and dead OpenJDK constants are pruned from all Configurables.* partials.

Changes:

  • Add src/openjdk (download/verify/extract/install Microsoft OpenJDK) and src/androidsdk (accept SDK licenses), wired in via Xamarin.Android.sln and ProjectReferences.
  • Delete Step_InstallAdoptOpenJDK*.cs, Step_Android_SDK_NDK.AcceptLicenses, and unused MicrosoftOpenJDK*/AdoptOpenJDK*/OpenJDKInstallDir/OpenJDKCacheDir definitions; remove the OpenJDK steps from the standard and test scenarios.
  • Drop all JI_JAVA_HOME/JI_JAVA_HOME_DEFAULT usage from setup-jdk-variables.yaml, azure-pipelines-nightly.yaml, OS.InitOS, and AndroidSdkResolver; introduce a CI step that builds androidsdk.csproj to perform the JDK install + license acceptance.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
Xamarin.Android.slnRegisters the new openjdk and androidsdk projects.
Configuration.propsIntroduces MicrosoftOpenJDKVersion/Folder/RootDirName and unconditionally sets JavaSdkDirectory to the install location.
src/openjdk/openjdk.csproj, openjdk.targetsNew NoTargets project that downloads, hash-verifies, extracts, and installs the Microsoft OpenJDK.
src/androidsdk/androidsdk.csproj, androidsdk.targetsNew NoTargets project that runs sdkmanager --licenses to accept Android SDK licenses, taking a ProjectReference on openjdk.
src/manifestmerger/manifestmerger.csproj, src/r8/r8.csproj, src/proguard-android/proguard-android.csproj, src/bundletool/bundletool.csproj, src/java-runtime/java-runtime.csprojAdd ProjectReference to androidsdk so JDK is available before gradle/jar/javac steps.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csprojAdds ProjectReference to androidsdk for test environment.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.csRemoves JI_JAVA_HOME lookup.
build-tools/xaprepare/.../Step_InstallAdoptOpenJDK*.csDeletes all five OpenJDK install step files.
build-tools/xaprepare/.../Step_Android_SDK_NDK.csRemoves AcceptLicenses and its callers (now handled by androidsdk.csproj).
build-tools/xaprepare/.../Scenario_Standard.cs, Scenario_AndroidTestDependencies.cs, Scenario_EmulatorTestDependencies.csDrops Step_InstallMicrosoftOpenJDK and updates descriptions.
build-tools/xaprepare/.../OperatingSystems/OS.csJavaHome no longer falls back to JI_JAVA_HOME.
build-tools/xaprepare/.../ConfigAndData/Configurables*.csRemoves unused OpenJDK constants, URLs, paths, and cached fields.
build-tools/automation/yaml-templates/setup-test-environment-steps.yamlAdds a step that builds androidsdk.csproj to install JDK and accept licenses.
build-tools/automation/yaml-templates/setup-jdk-variables.yamlStops setting JI_JAVA_HOME / JI_JAVA_HOME_DEFAULT.
build-tools/automation/azure-pipelines-nightly.yamlSwitches JavaSdkDirectory arg from $(JI_JAVA_HOME_DEFAULT) to $(JAVA_HOME).

Comment threadsrc/androidsdk/androidsdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/openjdk/openjdk.targets
Comment threadConfiguration.props
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/proguard-android/proguard-android.csproj

@github-actionsgithub-actionsBot 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.

✅ LGTM

Clean, well-structured migration that follows the established binutils pattern. The dependency graph (projects → androidsdkopenjdk) correctly ensures JDK is installed before any Java-dependent build step, and the removal of JI_JAVA_HOME simplifies CI without leaving dangling references.

Positive callouts:

  • SHA-256 hash verification of downloads is a good security improvement over the old code (which only checked version strings)
  • Incremental build support via Inputs/Outputs on all targets is correct
  • The separation of openjdk (download/install JDK) from androidsdk (accept licenses) is a clean abstraction
  • CI yaml cleanup (removing JI_JAVA_HOME, JI_JAVA_HOME_DEFAULT) is thorough

Issues: 0 ❌ | 0 ⚠️ | 2 💡

Generated by Android PR Reviewer for issue #11348 · ● 12.6M

Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 98a580f to 59f1c2aCompareMay 18, 2026 19:41
Fix 1: PowerShell "y" * 10 produces one string "yyyyyyyyyy", not 10
separate lines. Use 1..10 | ForEach-Object { "y" } instead.
Fix 2: Simplify JDK installation to a single tar call that extracts
directly into the install directory using --strip-components to flatten
the archive root folder. Windows 10+ includes bsdtar which handles
both .zip and .tar.gz. On macOS, strip 3 levels (jdk-X/Contents/Home)
vs 1 level (jdk-X) on Windows/Linux.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 59f1c2a to 3eaa5dfCompareMay 18, 2026 19:43
The macOS tar.gz has ./jdk-21.0.8+9/Contents/Home/bin/javac (4 levels)
while Windows/Linux have jdk-21.0.8+9/bin/javac (1 level). The leading
./ is counted by --strip-components, so macOS needs 4 not 3.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@simonrozsival
simonrozsival merged commit 0be3e63 into mainMay 20, 2026
3 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers/openjdk-msbuild-project branch May 20, 2026 21:01
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jun 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis 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.

3 participants

@jonathanpeppers@simonrozsival
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Move OpenJDK installation from xaprepare to MSBuild NoTargets project - #11348

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project
May 20, 2026
Merged

Move OpenJDK installation from xaprepare to MSBuild NoTargets project#11348
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Migrates the JDK download/install from the xaprepare bootstrapper (Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets project, modeled after src/binutils.

New src/openjdk project

  • Downloads the Microsoft OpenJDK archive (platform-specific)
  • Downloads and verifies hash of all downloads
  • Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
  • Supports incremental builds via MSBuild Inputs/Outputs
  • Validates root directory and key JDK files after install
  • Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
  • Handles macOS Contents/Home subdirectory structure

ProjectReferences

Projects that depend on the JDK now have a ProjectReference to src/openjdk, ensuring correct build ordering:

  • src/manifestmerger (gradle + JAVA_HOME)
  • src/r8 (gradle + JAVA_HOME)
  • src/proguard-android (gradle + JAVA_HOME)
  • src/bundletool (uses jar to extract/repack)
  • src/java-runtime (uses javac, jar, java)

Cleanup

  • Deletes all 5 Step_InstallAdoptOpenJDK*.cs files
  • Removes unused constants from all Configurables partial files
  • Removes JI_JAVA_HOME usage (redundant alias for JAVA_HOME set in CI)
  • Removes xaprepare scenario steps that installed OpenJDK

jonathanpeppersand others added 2 commits May 14, 2026 09:04
Migrate the JDK download/install from the xaprepare bootstrapper
(Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets
project, modeled after src/binutils.
The new project:
- Downloads the Microsoft OpenJDK archive (platform-specific)
- Downloads and verifies hash of all downloads
- Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
- Supports incremental builds via MSBuild Inputs/Outputs
- Validates root directory and key JDK files after install
- Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
- Handles macOS Contents/Home subdirectory structure
Projects that depend on the JDK now have a ProjectReference to
src/openjdk, ensuring correct build ordering:
- src/manifestmerger (gradle + JAVA_HOME)
- src/r8 (gradle + JAVA_HOME)
- src/proguard-android (gradle + JAVA_HOME)
- src/bundletool (uses jar to extract/repack)
- src/java-runtime (uses javac, jar, java)
Also removes all JI_JAVA_HOME usage, which was a redundant alias for
JAVA_HOME set in CI pipelines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts project
Create a new src/androidsdk MSBuild NoTargets project that runs
sdkmanager --licenses with JAVA_HOME set correctly. This project
depends on src/openjdk via ProjectReference, ensuring the JDK is
installed before sdkmanager runs.
The gradle/JDK-dependent projects now reference androidsdk instead
of openjdk directly, since androidsdk transitively depends on openjdk.
Remove the AcceptLicenses method from xaprepare Step_Android_SDK_NDK,
which was failing in CI because it ran before the JDK was installed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 0381336 to e1571c5CompareMay 14, 2026 16:12
jonathanpeppersand others added 4 commits May 14, 2026 13:22
Test projects that import TestApks.targets call sdkmanager with
JAVA_HOME, so they need androidsdk to ensure the JDK is installed
first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rs.targets
Test binding projects that import Jar.targets call javac/jar with
JavaSdkDirectory, and Mono.Android imports JavaCallableWrappers.targets
which runs D8 with JAVA_HOME. Both need the JDK installed first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference in .targets files does not work. Add it directly to
Emulator.csproj which is the project built standalone by the CI
pipeline to start/stop the Android emulator. This ensures the JDK
is installed before sdkmanager is called.
Revert the ineffective .targets changes from the previous commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference from Emulator.csproj to androidsdk is not sufficient
because the project is built standalone by the pipeline and the
reference is not resolved in time. Add an explicit build step in
setup-test-environment-steps.yaml after xaprepare to ensure the JDK
is installed and SDK licenses are accepted before any test project
that needs Java runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 18, 2026 19:24
CopilotAI review requested due to automatic review settings May 18, 2026 19:24
@jonathanpeppers

Copy link
Copy Markdown
MemberAuthor

/review

@github-actions

github-actionsBot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

CopilotAI 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

Migrates Microsoft OpenJDK installation from the xaprepare C# bootstrapper (Step_InstallAdoptOpenJDK*) into a new MSBuild NoTargets project (src/openjdk), modeled after src/binutils. A second new MSBuild project (src/androidsdk) takes over Android SDK license acceptance (previously AcceptLicenses in Step_Android_SDK_NDK). Projects that need a JDK at build time (manifestmerger, r8, proguard-android, bundletool, java-runtime, and the test Emulator.csproj) gain a ProjectReference to androidsdk/openjdk to enforce build ordering. The JI_JAVA_HOME alias is removed across CI, MSBuild, and test helpers, and dead OpenJDK constants are pruned from all Configurables.* partials.

Changes:

  • Add src/openjdk (download/verify/extract/install Microsoft OpenJDK) and src/androidsdk (accept SDK licenses), wired in via Xamarin.Android.sln and ProjectReferences.
  • Delete Step_InstallAdoptOpenJDK*.cs, Step_Android_SDK_NDK.AcceptLicenses, and unused MicrosoftOpenJDK*/AdoptOpenJDK*/OpenJDKInstallDir/OpenJDKCacheDir definitions; remove the OpenJDK steps from the standard and test scenarios.
  • Drop all JI_JAVA_HOME/JI_JAVA_HOME_DEFAULT usage from setup-jdk-variables.yaml, azure-pipelines-nightly.yaml, OS.InitOS, and AndroidSdkResolver; introduce a CI step that builds androidsdk.csproj to perform the JDK install + license acceptance.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
Xamarin.Android.slnRegisters the new openjdk and androidsdk projects.
Configuration.propsIntroduces MicrosoftOpenJDKVersion/Folder/RootDirName and unconditionally sets JavaSdkDirectory to the install location.
src/openjdk/openjdk.csproj, openjdk.targetsNew NoTargets project that downloads, hash-verifies, extracts, and installs the Microsoft OpenJDK.
src/androidsdk/androidsdk.csproj, androidsdk.targetsNew NoTargets project that runs sdkmanager --licenses to accept Android SDK licenses, taking a ProjectReference on openjdk.
src/manifestmerger/manifestmerger.csproj, src/r8/r8.csproj, src/proguard-android/proguard-android.csproj, src/bundletool/bundletool.csproj, src/java-runtime/java-runtime.csprojAdd ProjectReference to androidsdk so JDK is available before gradle/jar/javac steps.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csprojAdds ProjectReference to androidsdk for test environment.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.csRemoves JI_JAVA_HOME lookup.
build-tools/xaprepare/.../Step_InstallAdoptOpenJDK*.csDeletes all five OpenJDK install step files.
build-tools/xaprepare/.../Step_Android_SDK_NDK.csRemoves AcceptLicenses and its callers (now handled by androidsdk.csproj).
build-tools/xaprepare/.../Scenario_Standard.cs, Scenario_AndroidTestDependencies.cs, Scenario_EmulatorTestDependencies.csDrops Step_InstallMicrosoftOpenJDK and updates descriptions.
build-tools/xaprepare/.../OperatingSystems/OS.csJavaHome no longer falls back to JI_JAVA_HOME.
build-tools/xaprepare/.../ConfigAndData/Configurables*.csRemoves unused OpenJDK constants, URLs, paths, and cached fields.
build-tools/automation/yaml-templates/setup-test-environment-steps.yamlAdds a step that builds androidsdk.csproj to install JDK and accept licenses.
build-tools/automation/yaml-templates/setup-jdk-variables.yamlStops setting JI_JAVA_HOME / JI_JAVA_HOME_DEFAULT.
build-tools/automation/azure-pipelines-nightly.yamlSwitches JavaSdkDirectory arg from $(JI_JAVA_HOME_DEFAULT) to $(JAVA_HOME).

Comment threadsrc/androidsdk/androidsdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/openjdk/openjdk.targets
Comment threadConfiguration.props
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/proguard-android/proguard-android.csproj

@github-actionsgithub-actionsBot 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.

✅ LGTM

Clean, well-structured migration that follows the established binutils pattern. The dependency graph (projects → androidsdkopenjdk) correctly ensures JDK is installed before any Java-dependent build step, and the removal of JI_JAVA_HOME simplifies CI without leaving dangling references.

Positive callouts:

  • SHA-256 hash verification of downloads is a good security improvement over the old code (which only checked version strings)
  • Incremental build support via Inputs/Outputs on all targets is correct
  • The separation of openjdk (download/install JDK) from androidsdk (accept licenses) is a clean abstraction
  • CI yaml cleanup (removing JI_JAVA_HOME, JI_JAVA_HOME_DEFAULT) is thorough

Issues: 0 ❌ | 0 ⚠️ | 2 💡

Generated by Android PR Reviewer for issue #11348 · ● 12.6M

Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 98a580f to 59f1c2aCompareMay 18, 2026 19:41
Fix 1: PowerShell "y" * 10 produces one string "yyyyyyyyyy", not 10
separate lines. Use 1..10 | ForEach-Object { "y" } instead.
Fix 2: Simplify JDK installation to a single tar call that extracts
directly into the install directory using --strip-components to flatten
the archive root folder. Windows 10+ includes bsdtar which handles
both .zip and .tar.gz. On macOS, strip 3 levels (jdk-X/Contents/Home)
vs 1 level (jdk-X) on Windows/Linux.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 59f1c2a to 3eaa5dfCompareMay 18, 2026 19:43
The macOS tar.gz has ./jdk-21.0.8+9/Contents/Home/bin/javac (4 levels)
while Windows/Linux have jdk-21.0.8+9/bin/javac (1 level). The leading
./ is counted by --strip-components, so macOS needs 4 not 3.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@simonrozsival
simonrozsival merged commit 0be3e63 into mainMay 20, 2026
3 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers/openjdk-msbuild-project branch May 20, 2026 21:01
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jun 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis 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.

3 participants

@jonathanpeppers@simonrozsival
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Move OpenJDK installation from xaprepare to MSBuild NoTargets project - #11348

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project
May 20, 2026
Merged

Move OpenJDK installation from xaprepare to MSBuild NoTargets project#11348
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Migrates the JDK download/install from the xaprepare bootstrapper (Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets project, modeled after src/binutils.

New src/openjdk project

  • Downloads the Microsoft OpenJDK archive (platform-specific)
  • Downloads and verifies hash of all downloads
  • Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
  • Supports incremental builds via MSBuild Inputs/Outputs
  • Validates root directory and key JDK files after install
  • Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
  • Handles macOS Contents/Home subdirectory structure

ProjectReferences

Projects that depend on the JDK now have a ProjectReference to src/openjdk, ensuring correct build ordering:

  • src/manifestmerger (gradle + JAVA_HOME)
  • src/r8 (gradle + JAVA_HOME)
  • src/proguard-android (gradle + JAVA_HOME)
  • src/bundletool (uses jar to extract/repack)
  • src/java-runtime (uses javac, jar, java)

Cleanup

  • Deletes all 5 Step_InstallAdoptOpenJDK*.cs files
  • Removes unused constants from all Configurables partial files
  • Removes JI_JAVA_HOME usage (redundant alias for JAVA_HOME set in CI)
  • Removes xaprepare scenario steps that installed OpenJDK

jonathanpeppersand others added 2 commits May 14, 2026 09:04
Migrate the JDK download/install from the xaprepare bootstrapper
(Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets
project, modeled after src/binutils.
The new project:
- Downloads the Microsoft OpenJDK archive (platform-specific)
- Downloads and verifies hash of all downloads
- Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
- Supports incremental builds via MSBuild Inputs/Outputs
- Validates root directory and key JDK files after install
- Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
- Handles macOS Contents/Home subdirectory structure
Projects that depend on the JDK now have a ProjectReference to
src/openjdk, ensuring correct build ordering:
- src/manifestmerger (gradle + JAVA_HOME)
- src/r8 (gradle + JAVA_HOME)
- src/proguard-android (gradle + JAVA_HOME)
- src/bundletool (uses jar to extract/repack)
- src/java-runtime (uses javac, jar, java)
Also removes all JI_JAVA_HOME usage, which was a redundant alias for
JAVA_HOME set in CI pipelines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts project
Create a new src/androidsdk MSBuild NoTargets project that runs
sdkmanager --licenses with JAVA_HOME set correctly. This project
depends on src/openjdk via ProjectReference, ensuring the JDK is
installed before sdkmanager runs.
The gradle/JDK-dependent projects now reference androidsdk instead
of openjdk directly, since androidsdk transitively depends on openjdk.
Remove the AcceptLicenses method from xaprepare Step_Android_SDK_NDK,
which was failing in CI because it ran before the JDK was installed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 0381336 to e1571c5CompareMay 14, 2026 16:12
jonathanpeppersand others added 4 commits May 14, 2026 13:22
Test projects that import TestApks.targets call sdkmanager with
JAVA_HOME, so they need androidsdk to ensure the JDK is installed
first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rs.targets
Test binding projects that import Jar.targets call javac/jar with
JavaSdkDirectory, and Mono.Android imports JavaCallableWrappers.targets
which runs D8 with JAVA_HOME. Both need the JDK installed first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference in .targets files does not work. Add it directly to
Emulator.csproj which is the project built standalone by the CI
pipeline to start/stop the Android emulator. This ensures the JDK
is installed before sdkmanager is called.
Revert the ineffective .targets changes from the previous commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference from Emulator.csproj to androidsdk is not sufficient
because the project is built standalone by the pipeline and the
reference is not resolved in time. Add an explicit build step in
setup-test-environment-steps.yaml after xaprepare to ensure the JDK
is installed and SDK licenses are accepted before any test project
that needs Java runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 18, 2026 19:24
CopilotAI review requested due to automatic review settings May 18, 2026 19:24
@jonathanpeppers

Copy link
Copy Markdown
MemberAuthor

/review

@github-actions

github-actionsBot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

CopilotAI 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

Migrates Microsoft OpenJDK installation from the xaprepare C# bootstrapper (Step_InstallAdoptOpenJDK*) into a new MSBuild NoTargets project (src/openjdk), modeled after src/binutils. A second new MSBuild project (src/androidsdk) takes over Android SDK license acceptance (previously AcceptLicenses in Step_Android_SDK_NDK). Projects that need a JDK at build time (manifestmerger, r8, proguard-android, bundletool, java-runtime, and the test Emulator.csproj) gain a ProjectReference to androidsdk/openjdk to enforce build ordering. The JI_JAVA_HOME alias is removed across CI, MSBuild, and test helpers, and dead OpenJDK constants are pruned from all Configurables.* partials.

Changes:

  • Add src/openjdk (download/verify/extract/install Microsoft OpenJDK) and src/androidsdk (accept SDK licenses), wired in via Xamarin.Android.sln and ProjectReferences.
  • Delete Step_InstallAdoptOpenJDK*.cs, Step_Android_SDK_NDK.AcceptLicenses, and unused MicrosoftOpenJDK*/AdoptOpenJDK*/OpenJDKInstallDir/OpenJDKCacheDir definitions; remove the OpenJDK steps from the standard and test scenarios.
  • Drop all JI_JAVA_HOME/JI_JAVA_HOME_DEFAULT usage from setup-jdk-variables.yaml, azure-pipelines-nightly.yaml, OS.InitOS, and AndroidSdkResolver; introduce a CI step that builds androidsdk.csproj to perform the JDK install + license acceptance.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
Xamarin.Android.slnRegisters the new openjdk and androidsdk projects.
Configuration.propsIntroduces MicrosoftOpenJDKVersion/Folder/RootDirName and unconditionally sets JavaSdkDirectory to the install location.
src/openjdk/openjdk.csproj, openjdk.targetsNew NoTargets project that downloads, hash-verifies, extracts, and installs the Microsoft OpenJDK.
src/androidsdk/androidsdk.csproj, androidsdk.targetsNew NoTargets project that runs sdkmanager --licenses to accept Android SDK licenses, taking a ProjectReference on openjdk.
src/manifestmerger/manifestmerger.csproj, src/r8/r8.csproj, src/proguard-android/proguard-android.csproj, src/bundletool/bundletool.csproj, src/java-runtime/java-runtime.csprojAdd ProjectReference to androidsdk so JDK is available before gradle/jar/javac steps.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csprojAdds ProjectReference to androidsdk for test environment.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.csRemoves JI_JAVA_HOME lookup.
build-tools/xaprepare/.../Step_InstallAdoptOpenJDK*.csDeletes all five OpenJDK install step files.
build-tools/xaprepare/.../Step_Android_SDK_NDK.csRemoves AcceptLicenses and its callers (now handled by androidsdk.csproj).
build-tools/xaprepare/.../Scenario_Standard.cs, Scenario_AndroidTestDependencies.cs, Scenario_EmulatorTestDependencies.csDrops Step_InstallMicrosoftOpenJDK and updates descriptions.
build-tools/xaprepare/.../OperatingSystems/OS.csJavaHome no longer falls back to JI_JAVA_HOME.
build-tools/xaprepare/.../ConfigAndData/Configurables*.csRemoves unused OpenJDK constants, URLs, paths, and cached fields.
build-tools/automation/yaml-templates/setup-test-environment-steps.yamlAdds a step that builds androidsdk.csproj to install JDK and accept licenses.
build-tools/automation/yaml-templates/setup-jdk-variables.yamlStops setting JI_JAVA_HOME / JI_JAVA_HOME_DEFAULT.
build-tools/automation/azure-pipelines-nightly.yamlSwitches JavaSdkDirectory arg from $(JI_JAVA_HOME_DEFAULT) to $(JAVA_HOME).

Comment threadsrc/androidsdk/androidsdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/openjdk/openjdk.targets
Comment threadConfiguration.props
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/proguard-android/proguard-android.csproj

@github-actionsgithub-actionsBot 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.

✅ LGTM

Clean, well-structured migration that follows the established binutils pattern. The dependency graph (projects → androidsdkopenjdk) correctly ensures JDK is installed before any Java-dependent build step, and the removal of JI_JAVA_HOME simplifies CI without leaving dangling references.

Positive callouts:

  • SHA-256 hash verification of downloads is a good security improvement over the old code (which only checked version strings)
  • Incremental build support via Inputs/Outputs on all targets is correct
  • The separation of openjdk (download/install JDK) from androidsdk (accept licenses) is a clean abstraction
  • CI yaml cleanup (removing JI_JAVA_HOME, JI_JAVA_HOME_DEFAULT) is thorough

Issues: 0 ❌ | 0 ⚠️ | 2 💡

Generated by Android PR Reviewer for issue #11348 · ● 12.6M

Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 98a580f to 59f1c2aCompareMay 18, 2026 19:41
Fix 1: PowerShell "y" * 10 produces one string "yyyyyyyyyy", not 10
separate lines. Use 1..10 | ForEach-Object { "y" } instead.
Fix 2: Simplify JDK installation to a single tar call that extracts
directly into the install directory using --strip-components to flatten
the archive root folder. Windows 10+ includes bsdtar which handles
both .zip and .tar.gz. On macOS, strip 3 levels (jdk-X/Contents/Home)
vs 1 level (jdk-X) on Windows/Linux.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 59f1c2a to 3eaa5dfCompareMay 18, 2026 19:43
The macOS tar.gz has ./jdk-21.0.8+9/Contents/Home/bin/javac (4 levels)
while Windows/Linux have jdk-21.0.8+9/bin/javac (1 level). The leading
./ is counted by --strip-components, so macOS needs 4 not 3.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@simonrozsival
simonrozsival merged commit 0be3e63 into mainMay 20, 2026
3 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers/openjdk-msbuild-project branch May 20, 2026 21:01
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jun 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis 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.

3 participants

@jonathanpeppers@simonrozsival
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Move OpenJDK installation from xaprepare to MSBuild NoTargets project - #11348

Merged
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project
May 20, 2026
Merged

Move OpenJDK installation from xaprepare to MSBuild NoTargets project#11348
simonrozsival merged 8 commits into
mainfrom
jonathanpeppers/openjdk-msbuild-project

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Migrates the JDK download/install from the xaprepare bootstrapper (Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets project, modeled after src/binutils.

New src/openjdk project

  • Downloads the Microsoft OpenJDK archive (platform-specific)
  • Downloads and verifies hash of all downloads
  • Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
  • Supports incremental builds via MSBuild Inputs/Outputs
  • Validates root directory and key JDK files after install
  • Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
  • Handles macOS Contents/Home subdirectory structure

ProjectReferences

Projects that depend on the JDK now have a ProjectReference to src/openjdk, ensuring correct build ordering:

  • src/manifestmerger (gradle + JAVA_HOME)
  • src/r8 (gradle + JAVA_HOME)
  • src/proguard-android (gradle + JAVA_HOME)
  • src/bundletool (uses jar to extract/repack)
  • src/java-runtime (uses javac, jar, java)

Cleanup

  • Deletes all 5 Step_InstallAdoptOpenJDK*.cs files
  • Removes unused constants from all Configurables partial files
  • Removes JI_JAVA_HOME usage (redundant alias for JAVA_HOME set in CI)
  • Removes xaprepare scenario steps that installed OpenJDK

jonathanpeppersand others added 2 commits May 14, 2026 09:04
Migrate the JDK download/install from the xaprepare bootstrapper
(Step_InstallAdoptOpenJDK) to a new src/openjdk MSBuild NoTargets
project, modeled after src/binutils.
The new project:
- Downloads the Microsoft OpenJDK archive (platform-specific)
- Downloads and verifies hash of all downloads
- Extracts and installs to $(AndroidToolchainDirectory)/jdk-21
- Supports incremental builds via MSBuild Inputs/Outputs
- Validates root directory and key JDK files after install
- Handles Windows (.zip via Unzip task) and Linux/macOS (.tar.gz via tar)
- Handles macOS Contents/Home subdirectory structure
Projects that depend on the JDK now have a ProjectReference to
src/openjdk, ensuring correct build ordering:
- src/manifestmerger (gradle + JAVA_HOME)
- src/r8 (gradle + JAVA_HOME)
- src/proguard-android (gradle + JAVA_HOME)
- src/bundletool (uses jar to extract/repack)
- src/java-runtime (uses javac, jar, java)
Also removes all JI_JAVA_HOME usage, which was a redundant alias for
JAVA_HOME set in CI pipelines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ts project
Create a new src/androidsdk MSBuild NoTargets project that runs
sdkmanager --licenses with JAVA_HOME set correctly. This project
depends on src/openjdk via ProjectReference, ensuring the JDK is
installed before sdkmanager runs.
The gradle/JDK-dependent projects now reference androidsdk instead
of openjdk directly, since androidsdk transitively depends on openjdk.
Remove the AcceptLicenses method from xaprepare Step_Android_SDK_NDK,
which was failing in CI because it ran before the JDK was installed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 0381336 to e1571c5CompareMay 14, 2026 16:12
jonathanpeppersand others added 4 commits May 14, 2026 13:22
Test projects that import TestApks.targets call sdkmanager with
JAVA_HOME, so they need androidsdk to ensure the JDK is installed
first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rs.targets
Test binding projects that import Jar.targets call javac/jar with
JavaSdkDirectory, and Mono.Android imports JavaCallableWrappers.targets
which runs D8 with JAVA_HOME. Both need the JDK installed first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference in .targets files does not work. Add it directly to
Emulator.csproj which is the project built standalone by the CI
pipeline to start/stop the Android emulator. This ensures the JDK
is installed before sdkmanager is called.
Revert the ineffective .targets changes from the previous commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ProjectReference from Emulator.csproj to androidsdk is not sufficient
because the project is built standalone by the pipeline and the
reference is not resolved in time. Add an explicit build step in
setup-test-environment-steps.yaml after xaprepare to ensure the JDK
is installed and SDK licenses are accepted before any test project
that needs Java runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review May 18, 2026 19:24
CopilotAI review requested due to automatic review settings May 18, 2026 19:24
@jonathanpeppers

Copy link
Copy Markdown
MemberAuthor

/review

@github-actions

github-actionsBot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

CopilotAI 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

Migrates Microsoft OpenJDK installation from the xaprepare C# bootstrapper (Step_InstallAdoptOpenJDK*) into a new MSBuild NoTargets project (src/openjdk), modeled after src/binutils. A second new MSBuild project (src/androidsdk) takes over Android SDK license acceptance (previously AcceptLicenses in Step_Android_SDK_NDK). Projects that need a JDK at build time (manifestmerger, r8, proguard-android, bundletool, java-runtime, and the test Emulator.csproj) gain a ProjectReference to androidsdk/openjdk to enforce build ordering. The JI_JAVA_HOME alias is removed across CI, MSBuild, and test helpers, and dead OpenJDK constants are pruned from all Configurables.* partials.

Changes:

  • Add src/openjdk (download/verify/extract/install Microsoft OpenJDK) and src/androidsdk (accept SDK licenses), wired in via Xamarin.Android.sln and ProjectReferences.
  • Delete Step_InstallAdoptOpenJDK*.cs, Step_Android_SDK_NDK.AcceptLicenses, and unused MicrosoftOpenJDK*/AdoptOpenJDK*/OpenJDKInstallDir/OpenJDKCacheDir definitions; remove the OpenJDK steps from the standard and test scenarios.
  • Drop all JI_JAVA_HOME/JI_JAVA_HOME_DEFAULT usage from setup-jdk-variables.yaml, azure-pipelines-nightly.yaml, OS.InitOS, and AndroidSdkResolver; introduce a CI step that builds androidsdk.csproj to perform the JDK install + license acceptance.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 9 comments.

Show a summary per file
FileDescription
Xamarin.Android.slnRegisters the new openjdk and androidsdk projects.
Configuration.propsIntroduces MicrosoftOpenJDKVersion/Folder/RootDirName and unconditionally sets JavaSdkDirectory to the install location.
src/openjdk/openjdk.csproj, openjdk.targetsNew NoTargets project that downloads, hash-verifies, extracts, and installs the Microsoft OpenJDK.
src/androidsdk/androidsdk.csproj, androidsdk.targetsNew NoTargets project that runs sdkmanager --licenses to accept Android SDK licenses, taking a ProjectReference on openjdk.
src/manifestmerger/manifestmerger.csproj, src/r8/r8.csproj, src/proguard-android/proguard-android.csproj, src/bundletool/bundletool.csproj, src/java-runtime/java-runtime.csprojAdd ProjectReference to androidsdk so JDK is available before gradle/jar/javac steps.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csprojAdds ProjectReference to androidsdk for test environment.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.csRemoves JI_JAVA_HOME lookup.
build-tools/xaprepare/.../Step_InstallAdoptOpenJDK*.csDeletes all five OpenJDK install step files.
build-tools/xaprepare/.../Step_Android_SDK_NDK.csRemoves AcceptLicenses and its callers (now handled by androidsdk.csproj).
build-tools/xaprepare/.../Scenario_Standard.cs, Scenario_AndroidTestDependencies.cs, Scenario_EmulatorTestDependencies.csDrops Step_InstallMicrosoftOpenJDK and updates descriptions.
build-tools/xaprepare/.../OperatingSystems/OS.csJavaHome no longer falls back to JI_JAVA_HOME.
build-tools/xaprepare/.../ConfigAndData/Configurables*.csRemoves unused OpenJDK constants, URLs, paths, and cached fields.
build-tools/automation/yaml-templates/setup-test-environment-steps.yamlAdds a step that builds androidsdk.csproj to install JDK and accept licenses.
build-tools/automation/yaml-templates/setup-jdk-variables.yamlStops setting JI_JAVA_HOME / JI_JAVA_HOME_DEFAULT.
build-tools/automation/azure-pipelines-nightly.yamlSwitches JavaSdkDirectory arg from $(JI_JAVA_HOME_DEFAULT) to $(JAVA_HOME).

Comment threadsrc/androidsdk/androidsdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/openjdk/openjdk.targets
Comment threadConfiguration.props
Comment threadsrc/openjdk/openjdk.targets
Comment threadsrc/proguard-android/proguard-android.csproj

@github-actionsgithub-actionsBot 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.

✅ LGTM

Clean, well-structured migration that follows the established binutils pattern. The dependency graph (projects → androidsdkopenjdk) correctly ensures JDK is installed before any Java-dependent build step, and the removal of JI_JAVA_HOME simplifies CI without leaving dangling references.

Positive callouts:

  • SHA-256 hash verification of downloads is a good security improvement over the old code (which only checked version strings)
  • Incremental build support via Inputs/Outputs on all targets is correct
  • The separation of openjdk (download/install JDK) from androidsdk (accept licenses) is a clean abstraction
  • CI yaml cleanup (removing JI_JAVA_HOME, JI_JAVA_HOME_DEFAULT) is thorough

Issues: 0 ❌ | 0 ⚠️ | 2 💡

Generated by Android PR Reviewer for issue #11348 · ● 12.6M

Comment threadsrc/openjdk/openjdk.targets Outdated
Comment threadsrc/openjdk/openjdk.targets
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 98a580f to 59f1c2aCompareMay 18, 2026 19:41
Fix 1: PowerShell "y" * 10 produces one string "yyyyyyyyyy", not 10
separate lines. Use 1..10 | ForEach-Object { "y" } instead.
Fix 2: Simplify JDK installation to a single tar call that extracts
directly into the install directory using --strip-components to flatten
the archive root folder. Windows 10+ includes bsdtar which handles
both .zip and .tar.gz. On macOS, strip 3 levels (jdk-X/Contents/Home)
vs 1 level (jdk-X) on Windows/Linux.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppersforce-pushed the jonathanpeppers/openjdk-msbuild-project branch from 59f1c2a to 3eaa5dfCompareMay 18, 2026 19:43
The macOS tar.gz has ./jdk-21.0.8+9/Contents/Home/bin/javac (4 levels)
while Windows/Linux have jdk-21.0.8+9/bin/javac (1 level). The leading
./ is counted by --strip-components, so macOS needs 4 not 3.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 20, 2026
@simonrozsival
simonrozsival merged commit 0be3e63 into mainMay 20, 2026
3 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers/openjdk-msbuild-project branch May 20, 2026 21:01
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jun 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis 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.

3 participants

@jonathanpeppers@simonrozsival