From ad78579b6682a98e9af3bb04ac46ee8893ed201b Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Sun, 19 Feb 2023 19:19:49 -0800 Subject: [PATCH] Update java/build.gradle to not use deprecated features that were removed in gradle 8.0. (#14733) ### Description Update java/build.gradle to not use deprecated features that were removed in gradle 8.0. Also move gradle wrapper setup from a script into a step template. ### Motivation and Context Fix builds which use hosted Mac agents and gradle. Recently the system version of gradle got upgraded to 8.0. Even though we use an older gradle wrapper version, java/build.gradle is still processed with gradle 8.0 in the initial call to `gradle wrapper`. --- java/build.gradle | 8 ++++---- .../github/android/setup_gradle_wrapper.sh | 19 ------------------- ...ndroid-x86_64-crosscompile-ci-pipeline.yml | 15 +++++---------- .../templates/android-java-api-aar-test.yml | 3 +-- .../azure-pipelines/templates/mac-ci.yml | 2 ++ .../templates/react-native-ci.yml | 4 +--- .../templates/set-up-gradle-wrapper-step.yml | 10 ++++++++++ 7 files changed, 23 insertions(+), 38 deletions(-) delete mode 100755 tools/ci_build/github/android/setup_gradle_wrapper.sh create mode 100644 tools/ci_build/github/azure-pipelines/templates/set-up-gradle-wrapper-step.yml diff --git a/java/build.gradle b/java/build.gradle index b3a98f5cda..2dcd821f3d 100644 --- a/java/build.gradle +++ b/java/build.gradle @@ -42,7 +42,7 @@ jar { // Add explicit sources jar with pom file. task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" + archiveClassifier = "sources" from sourceSets.main.allSource into("META-INF/maven/$project.group/$mavenArtifactId") { from { generatePomFileForMavenPublication } @@ -52,7 +52,7 @@ task sourcesJar(type: Jar, dependsOn: classes) { // Add explicit javadoc jar with pom file task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = "javadoc" + archiveClassifier = "javadoc" from javadoc.destinationDir into("META-INF/maven/$project.group/$mavenArtifactId") { from { generatePomFileForMavenPublication } @@ -187,8 +187,8 @@ test { jacocoTestReport { reports { - xml.enabled true - csv.enabled true + xml.required = true + csv.required = true html.destination file("${buildDir}/jacocoHtml") } } diff --git a/tools/ci_build/github/android/setup_gradle_wrapper.sh b/tools/ci_build/github/android/setup_gradle_wrapper.sh deleted file mode 100755 index b5fa40dd25..0000000000 --- a/tools/ci_build/github/android/setup_gradle_wrapper.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# This script will setup gradlew to use gradle version 6.8.3 for Android CI, -# since the macOS pipeline is using gradle 7.0 which will fail the java build -# See, https://github.com/actions/virtual-environments/issues/3195 - -set -e -set -x - -if [ $# -ne 1 ]; then - echo "One command line argument, the ORT root directory, is expected" -fi - -ORT_ROOT=$1 - -pushd ${ORT_ROOT}/java -gradle wrapper --gradle-version 6.8.3 --no-daemon --no-watch-fs -./gradlew --version -popd diff --git a/tools/ci_build/github/azure-pipelines/android-x86_64-crosscompile-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/android-x86_64-crosscompile-ci-pipeline.yml index 7e8c3cfe37..4fd8d915f8 100644 --- a/tools/ci_build/github/azure-pipelines/android-x86_64-crosscompile-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/android-x86_64-crosscompile-ci-pipeline.yml @@ -46,8 +46,7 @@ stages: - template: "templates/use-android-ndk.yml" - - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) - displayName: Setup gradle wrapper to use gradle 6.8.3 + - template: templates/set-up-gradle-wrapper-step.yml # We build the host protoc to /protobuf_install - script: | @@ -131,8 +130,7 @@ stages: - template: "templates/use-android-ndk.yml" - - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) - displayName: Setup gradle wrapper to use gradle 6.8.3 + - template: templates/set-up-gradle-wrapper-step.yml # We build the host protoc to /protobuf_install - script: | @@ -235,8 +233,7 @@ stages: - template: "templates/use-android-ndk.yml" - - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) - displayName: Setup gradle wrapper to use gradle 6.8.3 + - template: templates/set-up-gradle-wrapper-step.yml - script: | python3 tools/python/run_android_emulator.py \ @@ -308,8 +305,7 @@ stages: - template: "templates/use-android-ndk.yml" - - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) - displayName: Setup gradle wrapper to use gradle 6.8.3 + - template: templates/set-up-gradle-wrapper-step.yml - script: | python3 tools/python/run_android_emulator.py \ @@ -391,8 +387,7 @@ stages: - template: "templates/use-android-ndk.yml" - - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) - displayName: Setup gradle wrapper to use gradle 6.8.3 + - template: templates/set-up-gradle-wrapper-step.yml # used by Build Minimal ORT - script: brew install coreutils ninja diff --git a/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar-test.yml b/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar-test.yml index 5c64f4b619..445a633d89 100644 --- a/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar-test.yml +++ b/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar-test.yml @@ -39,8 +39,7 @@ jobs: - template: use-android-ndk.yml - - script: /bin/bash tools/ci_build/github/android/setup_gradle_wrapper.sh $(Build.SourcesDirectory) - displayName: Setup gradle wrapper to use gradle 6.8.3 + - template: set-up-gradle-wrapper-step.yml - script: | python3 $(Build.SourcesDirectory)/tools/python/run_android_emulator.py \ diff --git a/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml b/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml index 280c321033..ea2f413b2b 100644 --- a/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml @@ -50,6 +50,8 @@ jobs: - template: set-version-number-variables-step.yml + - template: set-up-gradle-wrapper-step.yml + - script: | brew install ccache echo "##vso[task.prependpath]/usr/local/opt/ccache/libexec" diff --git a/tools/ci_build/github/azure-pipelines/templates/react-native-ci.yml b/tools/ci_build/github/azure-pipelines/templates/react-native-ci.yml index 33f6d1f871..4aa15af4be 100644 --- a/tools/ci_build/github/azure-pipelines/templates/react-native-ci.yml +++ b/tools/ci_build/github/azure-pipelines/templates/react-native-ci.yml @@ -60,9 +60,7 @@ jobs: brew install coreutils ninja npm yarn displayName: Install coreutils, ninja, npm, and yarn - - script: - /bin/bash $(Build.SourcesDirectory)/tools/ci_build/github/android/setup_gradle_wrapper.sh $(pwd) - displayName: Setup gradle wrapper to use gradle 6.8.3 + - template: set-up-gradle-wrapper-step.yml - script: | python3 -m pip install -q flatbuffers diff --git a/tools/ci_build/github/azure-pipelines/templates/set-up-gradle-wrapper-step.yml b/tools/ci_build/github/azure-pipelines/templates/set-up-gradle-wrapper-step.yml new file mode 100644 index 0000000000..8409288246 --- /dev/null +++ b/tools/ci_build/github/azure-pipelines/templates/set-up-gradle-wrapper-step.yml @@ -0,0 +1,10 @@ +parameters: +- name: GradleWrapperVersion + type: string + default: "6.8.3" + +steps: +- script: | + gradle wrapper --gradle-version="${{ parameters.GradleWrapperVersion }}" --no-daemon --no-watch-fs + displayName: Set up gradle ${{ parameters.GradleWrapperVersion }} wrapper + workingDirectory: $(Build.SourcesDirectory)/java