onnxruntime/java/build.gradle
stevenlix 814638cdff
Cherry pick PRs to Rel-1.3.1 (#4198)
* link to folder instead of READMEs inside folder (#3938)

otherwise hard to find the source code

* [Node.js binding] fix linux build (#3927)

* [Node.js binding] add build flag for node.js binding (#3948)

* [Nodejs binding] create a new pipeline to generate signed binaries (#4104)

* add yml files

* update pipeline

* fix yaml syntax

* yaml pop BuildCSharp

* udpate yaml

* do not stage codesign summary

* fix build: pipeline Node.js version to 12.16.3 (#4145)

* [Node.js binding] upgrade node-addon-api to 3.0 (#4148)

* [Node.js binding] add linux and mac package (#4157)

* try mac pipeline

* fix path separator

* copy prebuilds folder

* split esrp yaml for win/mac

* disable mac signing temporarily

* add linux

* fix indent

* add nodetool in linux

* add nodetool in win-ci-2019

* replace linux build by custom docker scripts

* use manylinux as node 12.16 not working on centos6

* try ubuntu

* loosen timeout for test case - multiple runs calls

* add script to support update nodejs binding version (#4164)

* [java] Adds a CUDA test (#3956)

* [java] - adding a cuda enabled test.

* Adding --build_java to the windows gpu ci pipeline.

* Removing a stray line from the unit tests that always enabled CUDA for Java.

* Update OnnxRuntime.java for OS X environment. (#3985)

onnxruntime init failure due to wrong path of reading native libraries. In OS X 64 system, the arch name is detected as x86 which generates invalid path to read native libraries.

Exception java.lang.UnsatisfiedLinkError: no onnxruntime in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
	at java.lang.Runtime.loadLibrary0(Runtime.java:870)
	at java.lang.System.loadLibrary(System.java:1122)
	at ai.onnxruntime.OnnxRuntime.load(OnnxRuntime.java:174)
	at ai.onnxruntime.OnnxRuntime.init(OnnxRuntime.java:81)
	at ai.onnxruntime.OrtEnvironment.<clinit>(OrtEnvironment.java:24)

* Create Java publishing pipeline (#3944)

Create CPU and GPu Java publishing pipelines. Final jars are tested on all platforms. However, signing and publishing to maven are manual steps.

* Change group id to com.microsoft.onnxruntime per requirements.

* Java GPu artifact naming (#4179)

Modify gradle build so artifactID has _gpu for GPU builds.
  Pass USE_CUDA flag on CUDA build
  Adjust publishing pipelines to extract POM from a correct path.

Co-Authored-By: @Craigacp

* bump up ORT version to 1.3.1 (#4181)

* move back to toolset 14.16 to possibly work around nvcc bug (#4180)

* Symbolic shape inference exit on models without onnx opset used (#4090)

* Symbolic shape inference exit on models without onnx opset used

* Temporary fix for ConvTranspose with symbolic input dims

Co-authored-by: Changming Sun <me@sunchangming.com>

* Fix Nuphar test failure

* Enlarge the read buffer size in C#/Java test code (#4150)

1. Enlarge the read buffer size further, so that our code can run even faster. TODO: need apply the similar changes to python some other language bindings.
2. Add coreml_VGG16_ImageNet to the test exclusion set of x86_32. It is not a new model but previously we didn't run the test against x86_32.

* Temporarily disable windows static analysis CI job

* skip model coreml_Imputer-LogisticRegression_sklearn_load_breast_cancer

* Delete unused variable

Co-authored-by: Prasanth Pulavarthi <prasantp@microsoft.com>
Co-authored-by: Yulong Wang <yulongw@microsoft.com>
Co-authored-by: Adam Pocock <adam.pocock@oracle.com>
Co-authored-by: jji2019 <49252772+jji2019@users.noreply.github.com>
Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com>
Co-authored-by: Dmitri Smirnov <dmitrism@microsoft.com>
Co-authored-by: George Wu <jywu@microsoft.com>
Co-authored-by: KeDengMS <kedeng@microsoft.com>
Co-authored-by: Changming Sun <me@sunchangming.com>
Co-authored-by: Changming Sun <chasun@microsoft.com>
2020-06-12 11:27:02 -07:00

221 lines
5.2 KiB
Groovy

plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'com.diffplug.gradle.spotless' version '3.26.0'
}
allprojects {
repositories {
mavenCentral()
}
}
project.group = "com.microsoft.onnxruntime"
version = rootProject.file('../VERSION_NUMBER').text.trim()
// cmake runs will inform us of the build directory of the current run
def cmakeBuildDir = System.properties['cmakeBuildDir']
def useCUDA = System.properties['USE_CUDA']
def cmakeJavaDir = "${cmakeBuildDir}/java"
def cmakeNativeLibDir = "${cmakeJavaDir}/native-lib"
def cmakeNativeJniDir = "${cmakeJavaDir}/native-jni"
def cmakeNativeTestDir = "${cmakeJavaDir}/native-test"
def cmakeBuildOutputDir = "${cmakeJavaDir}/build"
def mavenUser = System.properties['mavenUser']
def mavenPwd = System.properties['mavenPwd']
def mavenArtifactId = useCUDA != null ? project.name + "_gpu" : project.name
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// This jar tasks serves as a CMAKE signalling
// mechanism. The jar will be overwritten by allJar task
jar {
}
// Add explicit sources jar with pom file.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
into("META-INF/maven/$project.group/$mavenArtifactId") {
from { generatePomFileForMavenPublication }
rename ".*", "pom.xml"
}
}
// Add explicit javadoc jar with pom file
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.destinationDir
into("META-INF/maven/$project.group/$mavenArtifactId") {
from { generatePomFileForMavenPublication }
rename ".*", "pom.xml"
}
}
wrapper {
gradleVersion = '6.1.1'
}
spotless {
java {
removeUnusedImports()
googleJavaFormat()
}
format 'gradle', {
target '**/*.gradle'
trimTrailingWhitespace()
indentWithTabs()
}
}
compileJava {
options.compilerArgs += ["-h", "${project.buildDir}/headers/"]
}
sourceSets.test {
// add test resource files
resources.srcDirs += [
"${rootProject.projectDir}/../csharp/testdata",
"${rootProject.projectDir}/../onnxruntime/test/testdata",
"${rootProject.projectDir}/../java/testdata"
]
if (cmakeBuildDir != null) {
// add compiled native libs
resources.srcDirs += [
cmakeNativeLibDir,
cmakeNativeJniDir,
cmakeNativeTestDir
]
}
}
if (cmakeBuildDir != null) {
// generate tasks to be called from cmake
// Overwrite jar location
task allJar(type: Jar) {
manifest {
attributes('Automatic-Module-Name': project.group,
'Implementation-Title': 'onnxruntime',
'Implementation-Version': project.version)
}
into("META-INF/maven/$project.group/$mavenArtifactId") {
from { generatePomFileForMavenPublication }
rename ".*", "pom.xml"
}
from sourceSets.main.output
from cmakeNativeJniDir
from cmakeNativeLibDir
}
task cmakeBuild(type: Copy) {
from project.buildDir
include 'libs/**'
include 'docs/**'
into cmakeBuildOutputDir
}
cmakeBuild.dependsOn allJar
cmakeBuild.dependsOn sourcesJar
cmakeBuild.dependsOn javadocJar
cmakeBuild.dependsOn javadoc
task cmakeCheck(type: Copy) {
from project.buildDir
include 'reports/**'
into cmakeBuildOutputDir
}
cmakeCheck.dependsOn check
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.1'
testImplementation 'com.google.protobuf:protobuf-java:3.10.0'
}
test {
useJUnitPlatform()
if (cmakeBuildDir != null) {
workingDir cmakeBuildDir
}
systemProperties System.getProperties().subMap(['USE_CUDA'])
testLogging {
events "passed", "skipped", "failed"
showStandardStreams = true
}
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled true
html.destination file("${buildDir}/jacocoHtml")
}
}
publishing {
publications {
maven(MavenPublication) {
groupId = project.group
artifactId = mavenArtifactId
from components.java
pom {
name = 'onnx-runtime'
description = 'ONNX Runtime is a performance-focused inference engine for ONNX (Open Neural Network Exchange) models.'
url = 'https://microsoft.github.io/onnxruntime/'
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
organization {
name = 'Microsoft'
url = 'http://www.microsoft.com'
}
scm {
connection = 'scm:git:git://github.com:microsoft/onnxruntime.git'
developerConnection = 'scm:git:ssh://github.com/microsoft/onnxruntime.git'
url = 'http://github.com/microsoft/onnxruntime'
}
developers {
developer {
id = 'onnxruntime'
name = 'ONNX Runtime'
email = 'onnxruntime@microsoft.com'
}
}
}
}
}
repositories {
maven {
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username mavenUser
password mavenPwd
}
}
}
}
// Generates a task signMavenPublication that will
// build all artifacts.
signing {
// Queries env vars:
// ORG_GRADLE_PROJECT_signingKey
// ORG_GRADLE_PROJECT_signingPassword but can be changed to properties
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.maven
}