This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.gradle
217 lines (192 loc) · 9.69 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: "com.github.dcendents.android-maven"
apply plugin: "maven-publish"
apply plugin: "signing"
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName libraryVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8 /** Required for de-suraging */
targetCompatibility 1.8 /** Required for de-suraging */
}
testOptions {
unitTests.includeAndroidResources = true
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation deps.ktx
implementation deps.appcompat
implementation deps.android_material
api project(":design")
api project(":base-viewmodel")
api project(":base-viewmodel-impl")
api(project(":base")) {
exclude module: 'libsodium-jni'
}
implementation('com.github.joshjdevl.libsodiumjni:libsodium-jni-aar:2.0.1')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives androidSourcesJar
}
afterEvaluate {
// ================================================================================
// Built upon solutions presented here to build for multiple android flavors
// https://stackoverflow.com/questions/34331713/publishing-android-library-aar-to-bintray-with-chosen-flavors
// ================================================================================
def publicationNames = []
publishing {
publications {
android.libraryVariants.all { variant ->
if (variant.buildType.name == "debug") return // Prevents publishing debug library
def flavored = !variant.flavorName.isEmpty()
/**
* Translates "_" in flavor names to "-" for artifactIds, because "-" in flavor name is an
* illegal character, but is well used in artifactId names.
*/
def variantArtifactId = flavored ? "${project.name}-${variant.flavorName.replace('_', '-')}".replace('-normal', '') : project.name
/**
* If the javadoc destinationDir wasn't changed per flavor, the libraryVariants would
* overwrite the javaDoc as all variants would write in the same directory
* before the last javadoc jar would have been built, which would cause the last javadoc
* jar to include classes from other flavors that it doesn't include.
*
* Yes, tricky.
*
* Note that "${buildDir}/docs/javadoc" is the default javadoc destinationDir.
*/
def javaDocDestDir = file("${buildDir}/docs/javadoc ${flavored ? variantArtifactId : ""}")
/**
* Includes
*/
def javadoc = task("${variant.name}Javadoc", type: Javadoc) {
description "Generates Javadoc for ${variant.name}."
source = variant.javaCompileProvider.get().source
//variant.javaCompile.source // Yes, javaCompile is deprecated,
// but I didn't find any working alternative. Please, tweet @Louis_CAD if you find one.
destinationDir = javaDocDestDir
classpath += files(android.getBootClasspath().join(File.pathSeparator))
classpath += files(configurations.compile)
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.links("http://d.android.com/reference/");
exclude '**/BuildConfig.java'
exclude '**/R.java'
failOnError false
}
def javadocJar = task("${variant.name}JavadocJar", type: Jar, dependsOn: javadoc) {
description "Puts Javadoc for ${variant.name} in a jar."
classifier = 'javadoc'
from javadoc.destinationDir
}
def publicationName = "spend${variant.name.capitalize()}"
publicationNames.add(publicationName)
"$publicationName"(MavenPublication) {
artifactId variantArtifactId
group groupId
version libraryVersion
// This is the aar library
artifact variant.packageLibraryProvider.get().archivePath
artifact androidSourcesJar
artifact javadocJar
pom {
packaging 'aar'
name = 'spend'
description = "Kin Android SDK Spend"
url = 'https://github.com/kinecosystem/kin-android/tree/master/spend'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/kinecosystem/kin-android/blob/master/LICENSE.md'
}
}
scm {
connection = 'scm:git:github.com/kinecosystem/kin-android.git'
developerConnection = 'scm:git:ssh://github.com/kinecosystem/kin-android.git'
url = 'https://github.com/kinecosystem/kin-android/tree/master/spend'
}
developers {
developer {
id = 'kin-ci'
name = 'Kin CI'
email = '[email protected]'
}
}
withXml {
def root = asNode()
// root.appendNode("name", 'spend')
// root.appendNode("url", siteUrl)
root.children().last() //+ pomConfig
def depsNode = root["dependencies"][0] ?: root.appendNode("dependencies")
def addDep = {
if (it.group == null) return // Avoid empty dependency nodes
def dependencyNode = depsNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
if (it.hasProperty('targetConfiguration') && it.targetConfiguration != null) {
dependencyNode.appendNode('artifactId', "${it.name}-${it.targetConfiguration}")
} else {
dependencyNode.appendNode('artifactId', it.name)
}
dependencyNode.appendNode('version', it.version)
if (it.hasProperty('optional') && it.optional) {
dependencyNode.appendNode('optional', 'true')
}
if (it.hasProperty("excludeRules")) {
ArrayList<ExcludeRule> excludeRules = it.excludeRules
if (excludeRules.size() > 0) {
def exclusionsNode = dependencyNode.appendNode("exclusions")
it.excludeRules.each { ExcludeRule rule ->
def xmlExclusion = exclusionsNode.appendNode("exclusion")
if (rule.group != null && !(rule.group as String).isEmpty()) {
xmlExclusion.appendNode("groupId", rule.group)
} else {
xmlExclusion.appendNode("groupId", "*")
}
xmlExclusion.appendNode("artifactId", rule.module)
}
}
}
dependencyNode.appendNode("scope", "runtime")
}
// Add deps that everyone has
configurations.implementation.allDependencies.each addDep
// Add flavor specific deps
if (flavored) {
configurations["${variant.flavorName}Implementation"].allDependencies.each addDep
}
// NOTE: This library doesn't use builtTypes specific dependencies, so no need to add them.
}
}
}
}
}
}
}
ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
signing {
sign publishing.publications
}