microsoft/onnxruntime-extensions

Public

mirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
08659eae90f5df5cce12d5e02e6c97a0474d30ce

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

java/build-android.gradle

167lines · modecode

1apply plugin: 'com.android.library'
2apply plugin: 'maven-publish'
3
4def jniLibsDir = System.properties['jniLibsDir']
5def buildDir = System.properties['buildDir']
6def headersDir = System.properties['headersDir']
7def publishDir = System.properties['publishDir']
8def minSdkVer = System.properties['minSdkVer']
9def targetSdkVer = System.properties['targetSdkVer']
10def buildVariant = System.properties['buildVariant'] ?: "Full"
11boolean isMobileBuild = (buildVariant == "Mobile")
12
13// Since Android requires a higher numbers indicating more recent versions
14// This function assume ORT version number will be in formart of A.B.C such as 1.7.0
15// We generate version code A[0{0,1}]B[0{0,1}]C,
16// for example '1.7.0' -> 10700, '1.6.15' -> 10615
17def getVersionCode(String version){
18 String[] codes = version.split('\\.');
19 // This will have problem if we have 3 digit [sub]version number, such as 1.7.199
20 // but it is highly unlikely to happen
21 String versionCodeStr = String.format("%d%02d%02d", codes[0] as int, codes[1] as int, codes[2] as int);
22 return versionCodeStr as int;
23}
24
25project.buildDir = buildDir
26project.version = rootProject.file('../.version.txt').text.trim()
27project.group = "com.microsoft.onnxruntime.extensions"
28
29def mavenArtifactId = isMobileBuild ? project.name + '-mobile' : project.name + '-android'
30def mobileDescription = 'ONNXRuntime-Extensions Mobile is a library for Android for pre- and post-processing on inference.'
31def defaultDescription = 'ONNXRuntime-Extensions is a library for Android for pre- and post-processing on inference.'
32
33buildscript {
34 repositories {
35 google()
36 mavenCentral()
37 }
38 dependencies {
39 classpath 'com.android.tools.build:gradle:4.0.1'
40
41 // NOTE: Do not place your application dependencies here; they belong
42 // in the individual module build.gradle files
43 }
44}
45
46allprojects {
47 repositories {
48 google()
49 mavenCentral()
50 }
51}
52
53android {
54 compileSdkVersion 29
55 buildToolsVersion "29.0.2"
56
57 defaultConfig {
58 minSdkVersion minSdkVer
59 targetSdkVersion targetSdkVer
60 versionCode = getVersionCode(project.version)
61 versionName = project.version
62
63 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
64 }
65
66 android {
67 lintOptions {
68 abortOnError false
69 }
70 }
71
72 buildTypes {
73 release {
74 minifyEnabled false
75 debuggable false
76 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
77 }
78 }
79
80 compileOptions {
81 sourceCompatibility = JavaVersion.VERSION_1_8
82 targetCompatibility = JavaVersion.VERSION_1_8
83 }
84
85 sourceSets {
86 main {
87 jniLibs.srcDirs = [jniLibsDir]
88 }
89 }
90
91}
92
93task sourcesJar(type: Jar) {
94 classifier "sources"
95 from android.sourceSets.main.java.srcDirs
96}
97
98task javadoc(type: Javadoc) {
99 source = android.sourceSets.main.java.srcDirs
100 classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
101}
102
103task javadocJar(type: Jar, dependsOn: javadoc) {
104 classifier = 'javadoc'
105 from javadoc.destinationDir
106}
107
108artifacts {
109 archives javadocJar
110 archives sourcesJar
111}
112
113dependencies {
114 testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
115 testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
116 testImplementation 'com.google.protobuf:protobuf-java:3.20.1'
117}
118
119publishing {
120 publications {
121 maven(MavenPublication) {
122 groupId = project.group
123 artifactId = mavenArtifactId
124 version = project.version
125
126 // Three artifacts, the `aar`, the sources and the javadoc
127 artifact("$buildDir/outputs/aar/${project.name}-release.aar")
128 artifact javadocJar
129 artifact sourcesJar
130
131 pom {
132 name = 'onnxruntime-extensions'
133 description = isMobileBuild ? mobileDescription : defaultDescription
134 url = 'https://microsoft.github.io/onnxruntime/'
135 licenses {
136 license {
137 name = 'MIT License'
138 url = 'https://opensource.org/licenses/MIT'
139 }
140 }
141 organization {
142 name = 'Microsoft'
143 url = 'http://www.microsoft.com'
144 }
145 scm {
146 connection = 'scm:git:git://github.com:microsoft/onnxruntime-extensions.git'
147 developerConnection = 'scm:git:ssh://github.com/microsoft/onnxruntime-extensions.git'
148 url = 'http://github.com/microsoft/onnxruntime-extensions'
149 }
150 developers {
151 developer {
152 id = 'onnxruntime'
153 name = 'ONNX Runtime'
154 email = 'onnxruntime@microsoft.com'
155 }
156 }
157 }
158 }
159 }
160
161 //publish to filesystem repo
162 repositories{
163 maven {
164 url "$publishDir"
165 }
166 }
167}
168