-
Notifications
You must be signed in to change notification settings - Fork 90
/
build.gradle
254 lines (213 loc) · 7.3 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
group = ARTIFACT_GROUP
version = ARTIFACT_VERSION
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'signing'
ext {
artifactId = 'amplitude-android-sdk'
}
repositories {
// The order in which you list these repositories matter.
google()
jcenter()
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 14
// Note: Can't target to the latest 29 now, since running Robolectric tests on 29 will
// require Java 9 above. However, Android Studio will error out when setting up Java to 9
// above.
targetSdkVersion 28
buildConfigField "String", "AMPLITUDE_VERSION", "\"${version}\""
testInstrumentationRunner 'androidx.test.ext.junit.runners.AndroidJUnit4'
// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
}
lintOptions {
abortOnError true
textReport true
warningsAsErrors false
}
testOptions {
unitTests.includeAndroidResources = true
}
}
dependencies {
implementation 'com.amplitude:analytics-connector:1.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.2.2'
testImplementation 'org.robolectric:robolectric:4.3.1'
testImplementation 'org.robolectric:shadows-maps:3.4-rc2'
testImplementation 'org.powermock:powermock-module-junit4:1.6.6'
testImplementation 'org.powermock:powermock-module-junit4-rule:1.6.6'
testImplementation 'org.powermock:powermock-api-mockito:1.6.6'
testImplementation 'org.powermock:powermock-classloading-xstream:1.6.6'
testImplementation 'com.google.android:support-v4:r6'
testImplementation 'com.google.android.gms:play-services-ads:18.3.0'
testImplementation 'com.google.android.gms:play-services-base:17.1.0'
testImplementation 'org.json:json:20140107'
testImplementation "junit:junit:4.12"
// Core library
testImplementation 'androidx.test:core:1.2.0'
// AndroidJUnitRunner and JUnit Rules
testImplementation 'androidx.test:runner:1.2.0'
testImplementation 'androidx.test:rules:1.2.0'
// Assertions
testImplementation 'androidx.test.ext:junit:1.1.1'
}
File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value -> ext[name] = value }
}
// ======== For SDK Releases ========
uploadArchives {
repositories.mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
pom.groupId = ARTIFACT_GROUP
pom.version = ARTIFACT_VERSION
pom.project {
name project.name
version ARTIFACT_VERSION
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email POM_DEVELOPER_EMAIL
organization POM_DEVELOPER_ORG
organizationUrl POM_DEVELOPER_ORG_URL
}
}
}
pom.whenConfigured { pom ->
pom.dependencies*.optional = true
pom.dependencies.find { dep ->
dep.groupId == 'com.amplitude' && dep.artifactId == 'analytics-connector'
}.optional = false
}
repository(url: RELEASE_REPOSITORY_URL) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: SNAPSHOT_REPOSITORY_URL) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
}
}
task install(type: Upload, dependsOn: assemble) {
repositories.mavenInstaller {
configuration = configurations.archives
pom.groupId = ARTIFACT_GROUP
pom.version = ARTIFACT_VERSION
pom.project {
name project.name
version ARTIFACT_VERSION
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
email POM_DEVELOPER_EMAIL
organization POM_DEVELOPER_ORG
organizationUrl POM_DEVELOPER_ORG_URL
}
}
}
}
}
task androidJavadocs(type: Javadoc, dependsOn: ':generateReleaseBuildConfig') {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += project.files('build/generated/source/buildConfig/release')
exclude(
'**/R.*',
'**/security/**',
'**/unity/**',
'**/api/AmplitudeLog.java',
'**/api/Constants.java',
'**/api/DeviceInfo.java',
'**/api/Utils.java',
'**/api/WorkerThread.java',
'**/api/CursorWindowAllocationException.java'
)
options {
encoding = 'UTF-8'
docEncoding = 'UTF-8'
charSet = 'UTF-8'
}
failOnError false
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask(":uploadArchives") }
sign configurations.archives
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
def isReleaseBuild() {
return version.contains("SNAPSHOT") == false
}
def getRepositoryUsername() {
return hasProperty('sonatypeUsername') ? sonatypeUsername : ""
}
def getRepositoryPassword() {
return hasProperty('sonatypePassword') ? sonatypePassword : ""
}