microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
cfd9f2bd7aca5ce46f37b066d474afda40f6ddec

Branches

Tags

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

Clone

HTTPS

Download ZIP

java/build-android.gradle

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