microsoft/onnxruntime-extensions

Public

mirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
sayanshaw/speculative-bpe

Branches

Tags

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

Clone

HTTPS

Download ZIP

java/build-android.gradle

172lines · modecode

1apply plugin: 'com.android.library'
2apply plugin: 'maven-publish'
3
4def jniLibsDir = System.properties['jniLibsDir']
5def buildDir = System.properties['buildDir']
6def publishDir = System.properties['publishDir']
7def minSdkVer = System.properties['minSdkVer'] ?: 24
8def targetSdkVer = System.properties['targetSdkVer'] ?: 32
9def ndkVer = System.properties['ndkVer'] ?: "25.1.8937393"
10
11// Since Android requires a higher numbers indicating more recent versions
12// This function assume ORT version number will be in format of A.B.C such as 1.7.0
13// We generate version code A[0{0,1}]B[0{0,1}]C,
14// for example '1.7.0' -> 10700, '1.6.15' -> 10615
15def getVersionCode(String version) {
16 String[] code = version.split('\\-')
17 String[] codes = code[0].split('\\.')
18 // This will have problem if we have 3 digit [sub]version number, such as 1.7.199
19 // but it is highly unlikely to happen
20 String versionCodeStr = String.format("%d%02d%02d", codes[0] as int, codes[1] as int, codes[2] as int)
21 return versionCodeStr as int
22}
23
24project.buildDir = buildDir
25project.group = "com.microsoft.onnxruntime"
26project.version = rootProject.file('../version.txt').text.trim()
27
28def mavenArtifactId = project.name + '-android'
29
30buildscript {
31 repositories {
32 google()
33 mavenCentral()
34 }
35 dependencies {
36 classpath 'com.android.tools.build:gradle:7.3.0'
37
38 // NOTE: Do not place your application dependencies here; they belong
39 // in the individual module build.gradle files
40 }
41}
42
43allprojects {
44 repositories {
45 google()
46 mavenCentral()
47 }
48}
49
50android {
51 compileSdkVersion 32
52 ndkVersion ndkVer
53 defaultConfig {
54 minSdkVersion minSdkVer
55 targetSdkVersion targetSdkVer
56 versionCode = getVersionCode(project.version)
57 versionName = project.version
58
59 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
60
61 ndk {
62 abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
63 }
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 publishing {
92 singleVariant("release") {
93 withSourcesJar()
94 withJavadocJar()
95 }
96 }
97
98}
99
100task sourcesJar(type: Jar) {
101 archiveClassifier = "sources"
102 from android.sourceSets.main.java.srcDirs
103}
104
105task javadoc(type: Javadoc) {
106 source = android.sourceSets.main.java.srcDirs
107 classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
108}
109
110task javadocJar(type: Jar, dependsOn: javadoc) {
111 archiveClassifier = 'javadoc'
112 from javadoc.destinationDir
113}
114
115artifacts {
116 archives javadocJar
117 archives sourcesJar
118}
119
120dependencies {
121 testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
122 testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
123 testImplementation 'com.google.protobuf:protobuf-java:3.21.7'
124}
125
126project.afterEvaluate {
127 publishing {
128 publications {
129 maven(MavenPublication) {
130 from components.release
131 groupId = project.group
132 artifactId = mavenArtifactId
133 version = project.version
134
135 pom {
136 name = 'onnxruntime-extensions'
137 description = 'ONNXRuntime-Extensions is a library for Android for pre- and post-processing.'
138 url = 'https://microsoft.github.io/onnxruntime/'
139 licenses {
140 license {
141 name = 'MIT License'
142 url = 'https://opensource.org/licenses/MIT'
143 }
144 }
145 organization {
146 name = 'Microsoft'
147 url = 'http://www.microsoft.com'
148 }
149 scm {
150 connection = 'scm:git:git://github.com:microsoft/onnxruntime-extensions.git'
151 developerConnection = 'scm:git:ssh://github.com/microsoft/onnxruntime-extensions.git'
152 url = 'http://github.com/microsoft/onnxruntime-extensions'
153 }
154 developers {
155 developer {
156 id = 'onnxruntime'
157 name = 'ONNX Runtime'
158 email = 'onnxruntime@microsoft.com'
159 }
160 }
161 }
162 }
163 }
164
165 //publish to filesystem repo
166 repositories {
167 maven {
168 url "$publishDir"
169 }
170 }
171 }
172}
173