Update java/build.gradle to not use deprecated features that were removed in gradle 8.0. (#14733)

### Description
<!-- Describe your changes. -->

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
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

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`.
This commit is contained in:
Edward Chen 2023-02-19 19:19:49 -08:00 committed by GitHub
parent 8372c86e7f
commit ad78579b66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 38 deletions

View file

@ -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")
}
}

View file

@ -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

View file

@ -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 <ORT_ROOT>/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 <ORT_ROOT>/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

View file

@ -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 \

View file

@ -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"

View file

@ -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

View file

@ -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