microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
5e44a7c3c90cb9dc29f78c3322a60aa869dcf837

Branches

Tags

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

Clone

HTTPS

Download ZIP

java/build-android.gradle

163lines · 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.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
62 android {
63 lintOptions {
64 abortOnError false
65 }
66 }
67
68 buildTypes {
69 release {
70 minifyEnabled false
71 debuggable false
72 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
73 }
74 }
75
76 compileOptions {
77 sourceCompatibility = JavaVersion.VERSION_1_8
78 targetCompatibility = JavaVersion.VERSION_1_8
79 }
80
81 sourceSets {
82 main {
83 jniLibs.srcDirs = [jniLibsDir]
84 }
85 }
86
87}
88
89task sourcesJar(type: Jar) {
90 classifier "sources"
91 from android.sourceSets.main.java.srcDirs
92}
93
94task javadoc(type: Javadoc) {
95 source = android.sourceSets.main.java.srcDirs
96 classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
97}
98
99task javadocJar(type: Jar, dependsOn: javadoc) {
100 classifier = 'javadoc'
101 from javadoc.destinationDir
102}
103
104artifacts {
105 archives javadocJar
106 archives sourcesJar
107}
108
109dependencies {
110 testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
111 testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
112 testImplementation 'com.google.protobuf:protobuf-java:3.20.1'
113}
114
115publishing {
116 publications {
117 maven(MavenPublication) {
118 groupId = project.group
119 artifactId = mavenArtifactId
120 version = project.version
121
122 // Three artifacts, the `aar`, the sources and the javadoc
123 artifact("$buildDir/outputs/aar/${project.name}-release.aar")
124 artifact javadocJar
125 artifact sourcesJar
126
127 pom {
128 name = 'onnxruntime-extensions'
129 description = 'ONNXRuntime-Extensions is a library for Android for pre- and post-processing.'
130 url = 'https://microsoft.github.io/onnxruntime/'
131 licenses {
132 license {
133 name = 'MIT License'
134 url = 'https://opensource.org/licenses/MIT'
135 }
136 }
137 organization {
138 name = 'Microsoft'
139 url = 'http://www.microsoft.com'
140 }
141 scm {
142 connection = 'scm:git:git://github.com:microsoft/onnxruntime-extensions.git'
143 developerConnection = 'scm:git:ssh://github.com/microsoft/onnxruntime-extensions.git'
144 url = 'http://github.com/microsoft/onnxruntime-extensions'
145 }
146 developers {
147 developer {
148 id = 'onnxruntime'
149 name = 'ONNX Runtime'
150 email = 'onnxruntime@microsoft.com'
151 }
152 }
153 }
154 }
155 }
156
157 //publish to filesystem repo
158 repositories{
159 maven {
160 url "$publishDir"
161 }
162 }
163}
164