-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.gradle
295 lines (258 loc) · 10.6 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/****************************************************************************
* Copyright 2016-2021, Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.7.0'
ext.version_name = System.getenv('TRAVIS_TAG')
if (version_name == null || version_name.isEmpty()) {
ext.version_name = 'debugVersion'
}
ext.is_release_version = !version_name.endsWith("SNAPSHOT")
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id "org.jlleitschuh.gradle.ktlint" version "11.0.0"
}
allprojects {
tasks.withType(Test).configureEach {
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
if (!project.hasProperty("createReports")) {
reports.html.required = false
reports.junitXml.required = false
}
}
repositories {
jcenter()
google()
mavenCentral()
// SNAPSHOT support
maven {url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://jitpack.io" }
}
configurations.all {
// no cache for SNAPSHOT dependency
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
ext {
compile_sdk_version = 33
build_tools_version = "30.0.3"
min_sdk_version = 21
target_sdk_version = 33
java_core_ver = "4.2.0"
android_logger_ver = "1.3.6"
jacksonversion= "2.11.2"
annotations_ver = "1.2.0"
junit_ver = "4.12"
mockito_ver = "1.10.19"
powermock_ver = "2.0.9"
support_test_runner_ver = "0.5"
dexmaker_ver = "1.4"
gson_ver = "2.8.9"
group_id = "com.optimizely.ab"
work_runtime = "2.7.1"
androidx_test_junit = "1.1.3"
androidx_test_core = "1.4.0"
androidx_test_rules = "1.4.0"
espresso_ver = "3.4.0"
}
task clean(type: Delete) {
dependsOn('cleanAllModules')
}
task cleanAllModules () {
logger.info("Running clean for all modules")
dependsOn(':android-sdk:clean', ':event-handler:clean',
':user-profile:clean', ':shared:clean', ':datafile-handler:clean', ':odp:clean')
}
task testAllModules () {
logger.info("Running android tests for all modules")
dependsOn('testAllModulesTravis', ':test-app:connectedAndroidTest')
}
task testAllModulesTravis () {
logger.info("Running android tests for Travis")
dependsOn(':android-sdk:connectedAndroidTest', ':android-sdk:test',
':event-handler:connectedAndroidTest', ':event-handler:test',
':datafile-handler:connectedAndroidTest', ':datafile-handler:test',
':user-profile:connectedAndroidTest',
':shared:connectedAndroidTest',
':odp:connectedAndroidTest', ':odp:test'
)
}
// Publish to MavenCentral
task ship() {
dependsOn(':android-sdk:ship', ':shared:ship', ':event-handler:ship', ':user-profile:ship', ':datafile-handler:ship', ':odp:ship')
}
def publishedProjects = subprojects.findAll { it.name != 'test-app' }
configure(publishedProjects) {
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'
apply plugin: 'signing'
def artifactName = "android-sdk"
def docTitle = "Optimizely Android SDK"
switch(name){
case 'android-sdk':
artifactName = 'android-sdk'
docTitle = 'Optimizely Android SDK'
break
case 'datafile-handler':
artifactName = 'android-sdk-datafile-handler'
docTitle = 'Optimizely Android SDK: Datafile Handler'
break
case 'event-handler':
artifactName = 'android-sdk-event-handler'
docTitle = 'Optimizely Android SDK: Event Handler'
break
case 'shared':
artifactName = 'android-sdk-shared'
docTitle = 'Optimizely Android SDK: Shared'
break
case 'user-profile':
artifactName = 'android-sdk-user-profile'
docTitle = 'Optimizely X Android SDK: User Profile'
break
case 'odp':
artifactName = 'android-sdk-odp'
docTitle = 'Optimizely X Android SDK: ODP'
break
default:
return
}
android.libraryVariants.all { variant ->
task("${variant.name}Javadoc", type: Javadoc, dependsOn: "assemble${variant.name.capitalize()}") {
source = variant.javaCompileProvider.get().source
title = docTitle
options.links("http://docs.oracle.com/javase/7/docs/api/");
// First add all of your dependencies to the classpath, then add the android jars
doFirst {
classpath += files(variant.javaCompileProvider.get().classpath.files)
classpath += files(android.getBootClasspath())
}
// We're excluding these generated files
exclude '**/BuildConfig.java'
exclude '**/R.java'
options.tags = ["hide"]
}
}
android.libraryVariants.all { variant ->
task("${variant.name}JavadocJar", type: Jar, dependsOn: "${variant.name}Javadoc") {
classifier = 'javadoc'
from tasks["${variant.name}Javadoc"].destinationDir
}
// Add the Javadoc jar to the project's artifacts. This will allow us to upload it easily later
project.artifacts.add("archives", tasks["${variant.name}JavadocJar"]);
}
android.libraryVariants.all { variant ->
task("${variant.name}SourcesJar", type: Jar) {
classifier = 'sources'
from variant.javaCompileProvider.get().source
}
project.artifacts.add("archives", tasks["${variant.name}SourcesJar"]);
}
android {
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
version = version_name
group = group_id
artifactId = artifactName
customizePom(pom, docTitle)
// "description" is required by MavenCentral but it does not work in customizePom(). added here explicitly.
pom.description = 'The Android SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts'
from components.release
}
}
repositories {
maven {
def releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = is_release_version ? releaseUrl : snapshotUrl
credentials {
username System.getenv('MAVEN_CENTRAL_USERNAME')
password System.getenv('MAVEN_CENTRAL_PASSWORD')
}
}
}
}
signing {
// base64 for workaround travis escape chars issue
def signingKeyBase64 = System.getenv('MAVEN_SIGNING_KEY_BASE64')
// skip signing for "local" version into MavenLocal
if (!signingKeyBase64?.trim()) return
byte[] decoded = signingKeyBase64.decodeBase64()
def signingKey = new String(decoded)
def signingPassword = System.getenv('MAVEN_SIGNING_PASSPHRASE')
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.release
}
}
task ship() {
dependsOn('publish')
}
}
project(':android-sdk').ship.shouldRunAfter = [':android-sdk:clean', ':datafile-handler:ship', ':event-handler:ship', ':user-profile:ship', ':odp:ship']
project(':datafile-handler').ship.shouldRunAfter = [':datafile-handler:clean', ':shared:ship']
project(':event-handler').ship.shouldRunAfter = [':event-handler:clean', ':shared:ship']
project(':shared').ship.shouldRunAfter = [':shared:clean']
project(':user-profile').ship.shouldRunAfter = [':user-profile:clean', ':shared:ship']
project(':odp').ship.shouldRunAfter = [':odp:clean', ':shared:ship']
// standard POM format required by MavenCentral
def customizePom(pom, title) {
pom.withXml {
asNode().children().last() + {
// keep this - otherwise some properties are not made into pom properly
resolveStrategy = Closure.DELEGATE_FIRST
name title
url 'https://github.com/optimizely/android-sdk'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'optimizely'
name 'Optimizely'
email '[email protected]'
}
}
scm {
connection 'scm:git:git://github.com/optimizely/android-sdk.git'
developerConnection 'scm:git:ssh:github.com/optimizely/android-sdk.git'
url 'https://github.com/optimizely/android-sdk.git'
}
}
}
}