From e7d4b67242c98431e3dcf162fd3cba836e00d9a8 Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Thu, 5 Feb 2026 20:32:22 -0800 Subject: [PATCH 01/11] Fix Java Packaging missing Mac OS --- .../github/azure-pipelines/templates/c-api-cpu.yml | 4 ++++ .../templates/mac-cpu-packaging-steps.yml | 8 ++++++++ tools/ci_build/github/windows/jar_packaging.py | 1 + tools/ci_build/github/windows/jar_packaging_test.py | 12 ++++++++++-- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml index 5025046a02b0e..a0f023325be04 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml @@ -203,6 +203,10 @@ stages: - input: pipelineArtifact artifactName: drop-onnxruntime-java-linux-aarch64 targetPath: '$(Build.BinariesDirectory)\java-artifact\onnxruntime-java-linux-aarch64' + + - input: pipelineArtifact + artifactName: drop-onnxruntime-java-osx-arm64 + targetPath: '$(Build.BinariesDirectory)\java-artifact\onnxruntime-java-osx-arm64' outputs: - output: pipelineArtifact targetPath: $(Build.BinariesDirectory)\java-artifact\onnxruntime-java-win-x64 diff --git a/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packaging-steps.yml b/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packaging-steps.yml index 8e454f2137ce8..45f7268b9661d 100644 --- a/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packaging-steps.yml +++ b/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packaging-steps.yml @@ -40,6 +40,14 @@ steps: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: 'onnxruntime-osx-${{ parameters.MacosArch }}' +- template: java-api-artifacts-package-and-publish-steps-posix.yml + parameters: + arch: 'osx-${{ parameters.MacosArch }}' + buildConfig: 'Release' + artifactName: 'onnxruntime-java-osx-${{ parameters.MacosArch }}' + libraryName: 'libonnxruntime.dylib' + nativeLibraryName: 'libonnxruntime4j_jni.dylib' + - template: nodejs-artifacts-package-and-publish-steps-posix.yml parameters: arch: arm64 diff --git a/tools/ci_build/github/windows/jar_packaging.py b/tools/ci_build/github/windows/jar_packaging.py index 8ec380a5d2523..8588faa2bf6f9 100644 --- a/tools/ci_build/github/windows/jar_packaging.py +++ b/tools/ci_build/github/windows/jar_packaging.py @@ -232,6 +232,7 @@ def run_packaging(package_type: str, build_dir: str): "platforms": [ {"path": "onnxruntime-java-linux-x64", "lib": "libcustom_op_library.so", "archive_lib": True}, {"path": "onnxruntime-java-linux-aarch64", "lib": "libcustom_op_library.so", "archive_lib": False}, + {"path": "onnxruntime-java-osx-arm64", "lib": "libcustom_op_library.dylib", "archive_lib": False}, ] }, "gpu": { diff --git a/tools/ci_build/github/windows/jar_packaging_test.py b/tools/ci_build/github/windows/jar_packaging_test.py index 2dd61cf9c3088..e4f7e4945442c 100644 --- a/tools/ci_build/github/windows/jar_packaging_test.py +++ b/tools/ci_build/github/windows/jar_packaging_test.py @@ -52,14 +52,19 @@ def _setup_test_directory(package_type: str, version_string: str): create_empty_file(linux_native_dir / "libonnxruntime_providers_cuda.so") (linux_dir / "_manifest" / "spdx_2.2").mkdir(parents=True, exist_ok=True) - # --- Additional platforms (for CPU test) --- + # --- macOS and other platforms (for CPU test) --- if package_type == "cpu": - # Add linux-aarch64 for CPU test + # Add linux-aarch64 and osx-arm64 for CPU test linux_aarch64_dir = java_artifact_dir / "onnxruntime-java-linux-aarch64" linux_aarch64_native_dir = linux_aarch64_dir / "ai" / "onnxruntime" / "native" / "linux-aarch64" linux_aarch64_native_dir.mkdir(parents=True, exist_ok=True) create_empty_file(linux_aarch64_dir / "libcustom_op_library.so") + osx_arm64_dir = java_artifact_dir / "onnxruntime-java-osx-arm64" + osx_arm64_native_dir = osx_arm64_dir / "ai" / "onnxruntime" / "native" / "osx-arm64" + osx_arm64_native_dir.mkdir(parents=True, exist_ok=True) + create_empty_file(osx_arm64_dir / "libcustom_op_library.dylib") + return tmp_path return _setup_test_directory @@ -128,9 +133,12 @@ def test_cpu_packaging(directory_setup_factory, version_string): with zipfile.ZipFile(testing_jar_path, "r") as zf: jar_contents = zf.namelist() assert "libcustom_op_library.so" in jar_contents + assert "libcustom_op_library.dylib" in jar_contents # 3. Verify the custom op libraries were removed from the source directories linux_dir = temp_build_dir / "java-artifact" / "onnxruntime-java-linux-x64" linux_aarch64_dir = temp_build_dir / "java-artifact" / "onnxruntime-java-linux-aarch64" + osx_arm64_dir = temp_build_dir / "java-artifact" / "onnxruntime-java-osx-arm64" assert not (linux_dir / "libcustom_op_library.so").exists() assert not (linux_aarch64_dir / "libcustom_op_library.so").exists() + assert not (osx_arm64_dir / "libcustom_op_library.dylib").exists() From 9af75b068e59442152c97af861ff78bb9961a25e Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Thu, 5 Feb 2026 23:58:51 -0800 Subject: [PATCH 02/11] add --build_java --- .../github/azure-pipelines/templates/mac-cpu-packing-jobs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml b/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml index bfccaef1c9852..4b104130cbed3 100644 --- a/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml +++ b/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml @@ -45,9 +45,9 @@ jobs: set -e -x export ONNX_ML=1 export CMAKE_ARGS="-DONNX_GEN_PB_TYPE_STUBS=ON -DONNX_WERROR=OFF" - python3 -m pip install -r '$(Build.SourcesDirectory)/tools/ci_build/github/linux/docker/scripts/requirements.txt' + python3 -m pip install -r '$(Build.SourcesDirectory)/tools/ci_build/github/linux/docker/scripts/requirements.txt' - template: mac-cpu-packaging-steps.yml parameters: MacosArch: arm64 - AdditionalBuildFlags: ${{ parameters.AdditionalBuildFlags }} --build_nodejs --use_coreml --use_webgpu --cmake_extra_defines CMAKE_OSX_ARCHITECTURES=arm64 + AdditionalBuildFlags: ${{ parameters.AdditionalBuildFlags }} --build_java --build_nodejs --use_coreml --use_webgpu --cmake_extra_defines CMAKE_OSX_ARCHITECTURES=arm64 From 5ceac4353488bdc3581736ac5ce407db74bdac64 Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Fri, 6 Feb 2026 08:12:36 -0800 Subject: [PATCH 03/11] install JDK 17 --- .../templates/mac-cpu-packing-jobs.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml b/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml index 4b104130cbed3..de16ce483a9f4 100644 --- a/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml +++ b/tools/ci_build/github/azure-pipelines/templates/mac-cpu-packing-jobs.yml @@ -47,6 +47,17 @@ jobs: export CMAKE_ARGS="-DONNX_GEN_PB_TYPE_STUBS=ON -DONNX_WERROR=OFF" python3 -m pip install -r '$(Build.SourcesDirectory)/tools/ci_build/github/linux/docker/scripts/requirements.txt' + - script: | + set -e -x + if ! /usr/libexec/java_home -v 17 >/dev/null 2>&1; then + brew install --cask temurin@17 + fi + JAVA_HOME=$(/usr/libexec/java_home -v 17) + echo "JAVA_HOME is set to: $JAVA_HOME" + echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME" + echo "##vso[task.prependpath]$JAVA_HOME/bin" + displayName: 'Install JDK 17' + - template: mac-cpu-packaging-steps.yml parameters: MacosArch: arm64 From a94af708a29d11a806f929d85b6d72ac7b29618e Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Fri, 6 Feb 2026 10:14:52 -0800 Subject: [PATCH 04/11] add libcustom_op_library.dylib to testing.jar --- tools/ci_build/github/windows/jar_packaging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci_build/github/windows/jar_packaging.py b/tools/ci_build/github/windows/jar_packaging.py index 8588faa2bf6f9..f4bc6899260c1 100644 --- a/tools/ci_build/github/windows/jar_packaging.py +++ b/tools/ci_build/github/windows/jar_packaging.py @@ -232,7 +232,7 @@ def run_packaging(package_type: str, build_dir: str): "platforms": [ {"path": "onnxruntime-java-linux-x64", "lib": "libcustom_op_library.so", "archive_lib": True}, {"path": "onnxruntime-java-linux-aarch64", "lib": "libcustom_op_library.so", "archive_lib": False}, - {"path": "onnxruntime-java-osx-arm64", "lib": "libcustom_op_library.dylib", "archive_lib": False}, + {"path": "onnxruntime-java-osx-arm64", "lib": "libcustom_op_library.dylib", "archive_lib": True}, ] }, "gpu": { From 4ffd5b8b613641ee2c5fa53177fb4b6981d728bf Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Mon, 9 Feb 2026 22:58:00 -0800 Subject: [PATCH 05/11] test macos jar --- .../azure-pipelines/templates/final-jar-testing-linux.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml index f5ec5be2c1557..7678a89971ab3 100644 --- a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml +++ b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml @@ -64,10 +64,7 @@ stages: - task: Bash@3 displayName: 'Run Java Tests on Linux' -# condition: and(succeeded(), in(variables['Agent.OS'], 'Linux', 'Darwin')) - # MacOS packages have been removed from the JAR here: - # https://github.com/microsoft/onnxruntime/commit/5ed340f7a51f3cbdb62577a874daf2b3f23d6a93#diff-a14cc5ea231eb4fa49f13510a242043c47ae48516c860f8a87b0e55762632f49 - condition: and(succeeded(), in(variables['Agent.OS'], 'Linux')) + condition: and(succeeded(), in(variables['Agent.OS'], 'Linux', 'Darwin')) inputs: targetType: 'inline' script: | From 1bd62adf93ade93c1ac1898df654ebfce57b7ca4 Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Tue, 10 Feb 2026 00:46:07 -0800 Subject: [PATCH 06/11] Update LD_LIBRARY_PATH or DYLD_LIBRARY_PATH for ORT dll --- .../templates/final-jar-testing-linux.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml index 7678a89971ab3..e60dce58683ea 100644 --- a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml +++ b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml @@ -86,16 +86,28 @@ stages: echo "Java Version" java -version + # Set the correct library path based on the OS os_name=$(uname) + + # Find the directory containing the native library (libonnxruntime.so or libonnxruntime.dylib) + # The jar extraction puts them in ai/onnxruntime/native/... if [[ "$os_name" == "Linux" ]]; then + # Find the directory containing the native library (libonnxruntime.so) + NATIVE_LIB_DIR=$(find $(pwd) -name "libonnxruntime.so" | head -n 1 | xargs dirname) + echo "Found Linux native lib dir: $NATIVE_LIB_DIR" + echo "Platform: Linux. Setting LD_LIBRARY_PATH." - export LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" + export LD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$LD_LIBRARY_PATH" java -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \ --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults" elif [[ "$os_name" == "Darwin" ]]; then + # Find the directory containing the native library (libonnxruntime.dylib) + NATIVE_LIB_DIR=$(find $(pwd) -name "libonnxruntime.dylib" | head -n 1 | xargs dirname) + echo "Found macOS native lib dir: $NATIVE_LIB_DIR" + echo "Platform: macOS. Setting DYLD_LIBRARY_PATH." - export DYLD_LIBRARY_PATH="$(pwd):$DYLD_LIBRARY_PATH" + export DYLD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$DYLD_LIBRARY_PATH" java -DUSE_WEBGPU=1 -DUSE_COREML=1 -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \ --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults" fi From b44a9c981920b39e3a989f6e55ba135a7f4e2556 Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Tue, 10 Feb 2026 01:12:58 -0800 Subject: [PATCH 07/11] extract ort jar --- .../azure-pipelines/templates/final-jar-testing-linux.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml index e60dce58683ea..b4395eee52b18 100644 --- a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml +++ b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml @@ -82,7 +82,13 @@ stages: cd tests jar xf $(Pipeline.Workspace)/build/onnxruntime-java/testing.jar rm -f $(Pipeline.Workspace)/build/onnxruntime-java/testing.jar - ls $(Pipeline.Workspace)/build/tests + + # Identify main jar (avoiding sources and javadoc jars) + MAIN_JAR=$(ls $(Pipeline.Workspace)/build/onnxruntime-java/onnxruntime-*.jar | grep -v 'sources' | grep -v 'javadoc' | head -n 1) + echo "Extracting native libs from $MAIN_JAR" + jar xf $MAIN_JAR ai/onnxruntime/native + + ls -R $(Pipeline.Workspace)/build/tests/ai echo "Java Version" java -version From 2a2f05bd1eabbc9a4856673e89a818e6e3688a3c Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Tue, 10 Feb 2026 01:26:49 -0800 Subject: [PATCH 08/11] use macOS-15 pool --- .../azure-pipelines/jar_package_testing.yml | 2 +- .../templates/final-jar-testing-linux.yml | 65 ++++++++++++------- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/jar_package_testing.yml b/tools/ci_build/github/azure-pipelines/jar_package_testing.yml index 9d831df54096a..7ee180c13b2dc 100644 --- a/tools/ci_build/github/azure-pipelines/jar_package_testing.yml +++ b/tools/ci_build/github/azure-pipelines/jar_package_testing.yml @@ -21,7 +21,7 @@ stages: - template: templates/final-jar-testing-linux.yml parameters: OS: MacOS - PoolName: 'macOS-14' + PoolName: 'macOS-15' - stage: GPU_JAR_Testing dependsOn: [] diff --git a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml index b4395eee52b18..0e798cdec53d4 100644 --- a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml +++ b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml @@ -17,7 +17,14 @@ stages: clean: all ${{ if eq(parameters.OS, 'MacOS') }}: pool: - vmImage: 'macOS-15' + # Use PoolName if provided, otherwise fallback to macOS-15 + ${{ if ne(parameters.PoolName, '') }}: + ${{ if contains(parameters.PoolName, '-') }}: + vmImage: ${{ parameters.PoolName }} + ${{ else }}: + name: ${{ parameters.PoolName }} + ${{ else }}: + vmImage: 'macOS-15' ${{ if eq(parameters.OS, 'Linux') }}: pool: name: ${{ parameters.PoolName }} @@ -80,6 +87,14 @@ stages: cd .. mkdir tests cd tests + # 1. Diagnostics + echo "System Info:" + uname -a + if [[ "$(uname)" == "Darwin" ]]; then arch; fi + echo "Java Version" + java -version + + # 2. Extract jar xf $(Pipeline.Workspace)/build/onnxruntime-java/testing.jar rm -f $(Pipeline.Workspace)/build/onnxruntime-java/testing.jar @@ -93,29 +108,33 @@ stages: java -version - # Set the correct library path based on the OS + # 3. Find with robustness os_name=$(uname) - - # Find the directory containing the native library (libonnxruntime.so or libonnxruntime.dylib) - # The jar extraction puts them in ai/onnxruntime/native/... - if [[ "$os_name" == "Linux" ]]; then - # Find the directory containing the native library (libonnxruntime.so) - NATIVE_LIB_DIR=$(find $(pwd) -name "libonnxruntime.so" | head -n 1 | xargs dirname) - echo "Found Linux native lib dir: $NATIVE_LIB_DIR" - - echo "Platform: Linux. Setting LD_LIBRARY_PATH." - export LD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$LD_LIBRARY_PATH" - java -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \ - --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults" - elif [[ "$os_name" == "Darwin" ]]; then - # Find the directory containing the native library (libonnxruntime.dylib) - NATIVE_LIB_DIR=$(find $(pwd) -name "libonnxruntime.dylib" | head -n 1 | xargs dirname) - echo "Found macOS native lib dir: $NATIVE_LIB_DIR" - - echo "Platform: macOS. Setting DYLD_LIBRARY_PATH." - export DYLD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$DYLD_LIBRARY_PATH" - java -DUSE_WEBGPU=1 -DUSE_COREML=1 -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \ - --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults" + if [[ "$os_name" == "Linux" ]]; then S_FILE="libonnxruntime.so"; else S_FILE="libonnxruntime.dylib"; fi + + echo "Searching for $S_FILE in $(pwd)..." + # Exclude .dSYM paths and find actual file + NATIVE_LIB_PATH=$(find $(pwd) -name "$S_FILE" -not -path "*.dSYM*" -type f | head -n 1) + + if [[ -n "$NATIVE_LIB_PATH" ]]; then + NATIVE_LIB_DIR=$(dirname "$NATIVE_LIB_PATH") + echo "Found native lib dir: $NATIVE_LIB_DIR" + + if [[ "$os_name" == "Linux" ]]; then + echo "Platform: Linux. Setting LD_LIBRARY_PATH." + export LD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$LD_LIBRARY_PATH" + java -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \ + --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults" + elif [[ "$os_name" == "Darwin" ]]; then + echo "Platform: macOS. Setting DYLD_LIBRARY_PATH." + export DYLD_LIBRARY_PATH="$NATIVE_LIB_DIR:$(pwd):$DYLD_LIBRARY_PATH" + java -DUSE_WEBGPU=1 -DUSE_COREML=1 -cp '$(Pipeline.Workspace)/build/tests:$(Pipeline.Workspace)/build/onnxruntime-java/*' org.junit.platform.console.ConsoleLauncher --scan-classpath=$(Pipeline.Workspace)/build/tests \ + --fail-if-no-tests --disable-banner --reports-dir "$(Build.ArtifactStagingDirectory)/TestResults" + fi + else + echo "Error: $S_FILE not found!" + ls -R ai + exit 1 fi From c71beea22f45f2301e4e94b99e59811a177e55ee Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Tue, 10 Feb 2026 01:43:03 -0800 Subject: [PATCH 09/11] change pool for arm64 macos --- .../ci_build/github/azure-pipelines/jar_package_testing.yml | 3 ++- .../azure-pipelines/templates/final-jar-testing-linux.yml | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/ci_build/github/azure-pipelines/jar_package_testing.yml b/tools/ci_build/github/azure-pipelines/jar_package_testing.yml index 7ee180c13b2dc..275d911b7cca2 100644 --- a/tools/ci_build/github/azure-pipelines/jar_package_testing.yml +++ b/tools/ci_build/github/azure-pipelines/jar_package_testing.yml @@ -21,7 +21,8 @@ stages: - template: templates/final-jar-testing-linux.yml parameters: OS: MacOS - PoolName: 'macOS-15' + PoolName: 'AcesShared' + PoolDemands: 'ImageOverride -equals ACES_VM_SharedPool_Sequoia' - stage: GPU_JAR_Testing dependsOn: [] diff --git a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml index 0e798cdec53d4..389df634bfa49 100644 --- a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml +++ b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml @@ -8,6 +8,10 @@ parameters: - name: PoolName type: string +- name: PoolDemands + type: string + default: '' + stages: - stage: Final_Jar_Testing_${{parameters.OS}} dependsOn: [] @@ -23,6 +27,8 @@ stages: vmImage: ${{ parameters.PoolName }} ${{ else }}: name: ${{ parameters.PoolName }} + ${{ if ne(parameters.PoolDemands, '') }}: + demands: ${{ parameters.PoolDemands }} ${{ else }}: vmImage: 'macOS-15' ${{ if eq(parameters.OS, 'Linux') }}: From 83b4acdfd6bf55161d2996c737639975e126403d Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Tue, 10 Feb 2026 08:10:43 -0800 Subject: [PATCH 10/11] Install Maven in MacOS --- .../templates/final-jar-testing-linux.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml index 389df634bfa49..1247d597f0bcc 100644 --- a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml +++ b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml @@ -42,10 +42,15 @@ stages: - template: set-version-number-variables-step.yml - bash: | - echo "Downloading and installing Maven $(mavenVersion) for Linux..." + echo "Downloading and installing Maven $(mavenVersion)..." MAVEN_DIR="$(Agent.TempDirectory)/apache-maven-$(mavenVersion)" + # Download Maven binary - wget https://archive.apache.org/dist/maven/maven-3/$(mavenVersion)/binaries/apache-maven-$(mavenVersion)-bin.tar.gz -O $(Agent.TempDirectory)/maven.tar.gz + if command -v wget &> /dev/null; then + wget https://archive.apache.org/dist/maven/maven-3/$(mavenVersion)/binaries/apache-maven-$(mavenVersion)-bin.tar.gz -O $(Agent.TempDirectory)/maven.tar.gz + else + curl -L -o $(Agent.TempDirectory)/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/$(mavenVersion)/binaries/apache-maven-$(mavenVersion)-bin.tar.gz + fi # Extract to the temp directory mkdir -p ${MAVEN_DIR} @@ -53,8 +58,8 @@ stages: # Add Maven's bin directory to the PATH for subsequent tasks in the job echo "##vso[task.prependpath]${MAVEN_DIR}/bin" - displayName: 'Install Maven (Linux)' - condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) + displayName: 'Install Maven' + condition: and(succeeded(), in(variables['Agent.OS'], 'Linux', 'Darwin')) - script: | echo "Maven is now on the PATH." @@ -76,7 +81,7 @@ stages: mavenVersionOption: 'Default' - task: Bash@3 - displayName: 'Run Java Tests on Linux' + displayName: 'Run Java Tests' condition: and(succeeded(), in(variables['Agent.OS'], 'Linux', 'Darwin')) inputs: targetType: 'inline' From 51f07caf870ecd82b1ceb1c311017d577abb0234 Mon Sep 17 00:00:00 2001 From: Tianlei Wu Date: Tue, 10 Feb 2026 09:08:53 -0800 Subject: [PATCH 11/11] install JDK 17 for jar test --- .../templates/final-jar-testing-linux.yml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml index 1247d597f0bcc..738ac27bafde2 100644 --- a/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml +++ b/tools/ci_build/github/azure-pipelines/templates/final-jar-testing-linux.yml @@ -65,6 +65,18 @@ stages: echo "Maven is now on the PATH." mvn --version + - script: | + set -e -x + if ! /usr/libexec/java_home -v 17 >/dev/null 2>&1; then + brew install --cask temurin@17 + fi + JAVA_HOME=$(/usr/libexec/java_home -v 17) + echo "JAVA_HOME is set to: $JAVA_HOME" + echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME" + echo "##vso[task.prependpath]$JAVA_HOME/bin" + displayName: 'Install JDK 17 (macOS)' + condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) + - download: build artifact: 'onnxruntime-java' displayName: 'Download Final Jar' @@ -76,9 +88,13 @@ stages: goals: 'dependency:copy-dependencies' options: '-DoutputDirectory=$(Pipeline.Workspace)/build/onnxruntime-java' publishJUnitTestResults: false - javaHomeOption: 'JDKVersion' - jdkVersionOption: '1.17' mavenVersionOption: 'Default' + ${{ if eq(parameters.OS, 'MacOS') }}: + javaHomeOption: 'Path' + jdkDirectory: '$(JAVA_HOME)' + ${{ if eq(parameters.OS, 'Linux') }}: + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.17' - task: Bash@3 displayName: 'Run Java Tests'