Skip to content

Commit

Permalink
Refactor deprecated gradle syntax (#20922)
Browse files Browse the repository at this point in the history
To replaced deprecated API. 
Should verify with the `Gradle cmakeCheck` step from
`Windows_Packaging_CPU_x64_default` stage from the Zip-Nuge-...
pipeline.
  • Loading branch information
jchen351 authored Jun 7, 2024
1 parent 74028e4 commit d32adb2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ jar {
}

// Add explicit sources jar with pom file.
task sourcesJar(type: Jar, dependsOn: classes) {
tasks.register('sourcesJar', Jar) {
dependsOn classes
archiveClassifier = "sources"
from sourceSets.main.allSource
into("META-INF/maven/$project.group/$mavenArtifactId") {
Expand All @@ -70,7 +71,8 @@ task sourcesJar(type: Jar, dependsOn: classes) {
}

// Add explicit javadoc jar with pom file
task javadocJar(type: Jar, dependsOn: javadoc) {
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier = "javadoc"
from javadoc.destinationDir
into("META-INF/maven/$project.group/$mavenArtifactId") {
Expand All @@ -94,7 +96,7 @@ spotless {

compileJava {
dependsOn spotlessJava
options.compilerArgs += ["-h", "${project.buildDir}/headers/"]
options.compilerArgs += ["-h", "${layout.buildDirectory.get().toString()}/headers/"]
if (!JavaVersion.current().isJava8()) {
// Ensures only methods present in Java 8 are used
options.compilerArgs.addAll(['--release', '8'])
Expand Down Expand Up @@ -140,7 +142,7 @@ if (cmakeBuildDir != null) {
// generate tasks to be called from cmake

// Overwrite jar location
task allJar(type: Jar) {
tasks.register('allJar', Jar) {
manifest {
attributes('Automatic-Module-Name': project.group,
'Implementation-Title': 'onnxruntime',
Expand All @@ -155,23 +157,20 @@ if (cmakeBuildDir != null) {
from cmakeNativeLibDir
}

task cmakeBuild(type: Copy) {
from project.buildDir
tasks.register('cmakeBuild', Copy) {
from layout.buildDirectory.get()
include 'libs/**'
include 'docs/**'
into cmakeBuildOutputDir
dependsOn(allJar, sourcesJar, javadocJar, javadoc)
}
cmakeBuild.dependsOn allJar
cmakeBuild.dependsOn sourcesJar
cmakeBuild.dependsOn javadocJar
cmakeBuild.dependsOn javadoc

task cmakeCheck(type: Copy) {
from project.buildDir
tasks.register('cmakeCheck', Copy) {
from layout.buildDirectory.get()
include 'reports/**'
into cmakeBuildOutputDir
dependsOn(check)
}
cmakeCheck.dependsOn check
}

dependencies {
Expand Down Expand Up @@ -210,7 +209,7 @@ jacocoTestReport {
reports {
xml.required = true
csv.required = true
html.destination file("${buildDir}/jacocoHtml")
html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
}
}

Expand All @@ -225,6 +224,7 @@ publishing {
artifactId = mavenArtifactId
from components.java
}
version = project.version
pom {
name = enableTrainingApis ? 'onnxruntime-training' : 'onnx-runtime'
description = enableTrainingApis ? trainingDescription : defaultDescription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ steps:
inputs:
script: |
@echo on
call gradlew.bat cmakeCheck -DcmakeBuildDir=$(Build.BinariesDirectory)\RelWithDebInfo
call gradlew.bat cmakeCheck -DcmakeBuildDir=$(Build.BinariesDirectory)\RelWithDebInfo --warning-mode all
workingDirectory: $(Build.SourcesDirectory)\java

- task: CmdLine@2
Expand Down

0 comments on commit d32adb2

Please sign in to comment.