microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
440a3ca98b3104165c5c347ecf6adbbf4fdcce3b

Branches

Tags

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

Clone

HTTPS

Download ZIP

java/build-android.gradle

165lines · 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 formart 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.version = System.getenv('ORT_EXTENSIONS_AAR_VERSION') ?: rootProject.file('../version.txt').text.trim()
26project.group = "com.microsoft.onnxruntime"
27
28def mavenArtifactId = project.name + '-android'
29def defaultDescription = 'ONNXRuntime-Extensions is an extension of onnxruntime to support pre- and post-processing.'
30
31
32buildscript {
33 repositories {
34 google()
35 mavenCentral()
36 }
37 dependencies {
38 classpath 'com.android.tools.build:gradle:7.3.0'
39
40 // NOTE: Do not place your application dependencies here; they belong
41 // in the individual module build.gradle files
42 }
43}
44
45allprojects {
46 repositories {
47 google()
48 mavenCentral()
49 }
50}
51
52android {
53 compileSdkVersion 32
54 ndkVersion ndkVer
55 defaultConfig {
56 minSdkVersion minSdkVer
57 targetSdkVersion targetSdkVer
58 versionCode = getVersionCode(project.version)
59 versionName = project.version
60
61 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
62 }
63
64 android {
65 lintOptions {
66 abortOnError false
67 }
68 }
69
70 buildTypes {
71 release {
72 minifyEnabled false
73 debuggable false
74 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
75 }
76 }
77
78 compileOptions {
79 sourceCompatibility = JavaVersion.VERSION_1_8
80 targetCompatibility = JavaVersion.VERSION_1_8
81 }
82
83 sourceSets {
84 main {
85 jniLibs.srcDirs = [jniLibsDir]
86 }
87 }
88
89}
90
91task sourcesJar(type: Jar) {
92 classifier "sources"
93 from android.sourceSets.main.java.srcDirs
94}
95
96task javadoc(type: Javadoc) {
97 source = android.sourceSets.main.java.srcDirs
98 classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
99}
100
101task javadocJar(type: Jar, dependsOn: javadoc) {
102 classifier = 'javadoc'
103 from javadoc.destinationDir
104}
105
106artifacts {
107 archives javadocJar
108 archives sourcesJar
109}
110
111dependencies {
112 testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
113 testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
114 testImplementation 'com.google.protobuf:protobuf-java:3.20.1'
115}
116
117publishing {
118 publications {
119 maven(MavenPublication) {
120 groupId = project.group
121 artifactId = mavenArtifactId
122 version = project.version
123
124 // Three artifacts, the `aar`, the sources and the javadoc
125 artifact("$buildDir/outputs/aar/${project.name}-release.aar")
126 artifact javadocJar
127 artifact sourcesJar
128
129 pom {
130 name = 'onnxruntime-extensions'
131 description = defaultDescription
132 url = 'https://microsoft.github.io/onnxruntime/'
133 licenses {
134 license {
135 name = 'MIT License'
136 url = 'https://opensource.org/licenses/MIT'
137 }
138 }
139 organization {
140 name = 'Microsoft'
141 url = 'http://www.microsoft.com'
142 }
143 scm {
144 connection = 'scm:git:git://github.com:microsoft/onnxruntime-extensions.git'
145 developerConnection = 'scm:git:ssh://github.com/microsoft/onnxruntime-extensions.git'
146 url = 'http://github.com/microsoft/onnxruntime-extensions'
147 }
148 developers {
149 developer {
150 id = 'onnxruntime'
151 name = 'ONNX Runtime'
152 email = 'onnxruntime@microsoft.com'
153 }
154 }
155 }
156 }
157 }
158
159 //publish to filesystem repo
160 repositories{
161 maven {
162 url "$publishDir"
163 }
164 }
165}
166