-
Notifications
You must be signed in to change notification settings - Fork 622
/
build.gradle
120 lines (106 loc) · 3.88 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
android {
compileSdkVersion 32
buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 24
targetSdkVersion 32
versionCode 1
versionName "1.0"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}
sourceSets {
main {
jniLibs.srcDirs = ["jnilib/"]
}
}
}
// TODO: Making publish as an individual gradle file
signing {
required(project.hasProperty("staging") || project.hasProperty("snapshot"))
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
pom {
name = "PyTorch Android native library"
description = "PyTorch Android native library binary distribution"
url = "http://www.djl.ai/android"
packaging = "aar"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0"
}
}
scm {
connection = "scm:git:git@github.com:deepjavalibrary/djl.git"
developerConnection = "scm:git:git@github.com:deepjavalibrary/djl.git"
url = "https://github.com/deepjavalibrary/djl"
tag = "HEAD"
}
developers {
developer {
name = "DJL.AI Team"
email = "djl-dev@amazon.com"
organization = "Amazon AI"
organizationUrl = "https://amazon.com"
}
}
}
}
}
repositories {
maven {
if (project.hasProperty("snapshot")) {
name = "snapshot"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
credentials {
username = findProperty("ossrhUsername")
password = findProperty("ossrhPassword")
}
} else if (project.hasProperty("staging")) {
name = "staging"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = findProperty("ossrhUsername")
password = findProperty("ossrhPassword")
}
} else {
name = "local"
url = "build/repo"
}
}
}
}
}
task processResources {
doLast {
def url = "https://publish.djl.ai/pytorch/${pytorch_version}/jnilib/${djl_version}/android"
def abis = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
abis.each { abi ->
def downloadPath = new URL("${url}/${abi}/libdjl_torch.so")
def file = file("${project.projectDir}/jnilib/${abi}/libdjl_torch.so")
if (!file.exists()) {
project.logger.lifecycle("${url}/${abi}/libdjl_torch.so")
file.getParentFile().mkdirs()
downloadPath.withInputStream { i -> file.withOutputStream { it << i } }
}
}
}
}
assemble.dependsOn processResources