-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle
265 lines (225 loc) · 9.27 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
/**
* Copyright 2022 Adobe. All rights reserved.
* This file is licensed to you 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 REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
plugins {
id 'com.android.library'
id 'jacoco'
id 'maven-publish'
id 'signing'
id 'com.diffplug.spotless'
id 'kotlin-android'
}
// Apply local gradle tasks
apply from: '../codeformat.gradle'
jacoco {
toolVersion = rootProject.ext.jacocoVersion
}
if (project.hasProperty("signKeyLoc") && project.hasProperty("signKeyId") && project.hasProperty("signPass")) {
ext["signing.secretKeyRingFile"] = "$signKeyLoc"
ext["signing.keyId"] = "$signKeyId"
ext["signing.password"] = "$signPass"
}
if (project.hasProperty("sonatypeUser") && project.hasProperty("sonatypePass")) {
ext["ossrhUsername"] = "$sonatypeUser"
ext["ossrhPassword"] = "$sonatypePass"
} else {
ext["ossrhUsername"] = ""
ext["ossrhPassword"] = ""
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
// provides a major advantage by preventing the generation
// of individual png icons for each screen size in favor of a single vector
vectorDrawables.useSupportLibrary = true
buildConfigField("String","EXTENSION_VERSION","\"${rootProject.moduleVersion}\"")
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
flavorDimensions "target"
productFlavors {
phone {
dimension "target"
}
}
buildTypes {
debug {
testCoverageEnabled true
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.includeAndroidResources = true
}
compileOptions {
sourceCompatibility rootProject.ext.sourceCompatibility
targetCompatibility rootProject.ext.targetCompatibility
}
kotlinOptions {
jvmTarget = rootProject.ext.kotlinJvmTarget
languageVersion = rootProject.ext.kotlinLanguageVersion
apiVersion = rootProject.ext.kotlinApiVersion
}
}
afterEvaluate {
tasks.withType(Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += files(android.libraryVariants.collect { variant ->
variant.javaCompileProvider.get().classpath.files
})
options {
source = "8"
links "https://developer.android.com/reference"
}
}
}
task javadocInternal(type: Javadoc) {
destinationDir = reporting.file("javadocInternal")
options.memberLevel = JavadocMemberLevel.PRIVATE
}
task javadocPublic(type: Javadoc) {
destinationDir = reporting.file("javadocPublic")
options.memberLevel = JavadocMemberLevel.PUBLIC
}
task javadocPublish(type: Jar) {
from javadocPublic
archiveClassifier.set('javadoc')
}
def isJitPackBuild() {
return hasProperty('jitpack')
}
def groupIdForPublish = isJitPackBuild()? 'com.github.adobe.aepsdk-assurance-android': 'com.adobe.marketing.mobile'
def isReleaseBuild() {
return hasProperty('release')
}
version = isReleaseBuild() ? rootProject.moduleVersion : rootProject.moduleVersion+"-SNAPSHOT"
publish.dependsOn('assemblePhone')
publishToMavenLocal.dependsOn('assemblePhone')
tasks.withType(Javadoc).all { enabled = false }
publishing {
publications {
release(MavenPublication) {
groupId = groupIdForPublish
artifactId = rootProject.moduleName
version = version
artifact("$buildDir/outputs/aar/${rootProject.moduleAARName}")
artifact javadocPublish
pom {
name = mavenRepoName
description = mavenRepoDescription
url = 'https://developer.adobe.com/client-sdks'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = 'adobe'
name = 'adobe'
email = 'adobe-mobile-testing@adobe.com'
}
}
scm {
connection = 'scm:git:github.com//adobe/aepsdk-assurance-android.git'
developerConnection = 'scm:git:ssh://github.com//adobe/aepsdk-assurance-android.git'
url = 'https://github.com/adobe/aepsdk-assurance-android'
}
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
def coreDependencyNode = dependenciesNode.appendNode('dependency')
coreDependencyNode.appendNode('groupId', 'com.adobe.marketing.mobile')
coreDependencyNode.appendNode('artifactId', 'core')
coreDependencyNode.appendNode('version', mavenCoreVersion)
def constraintLayoutDependencyNode = dependenciesNode.appendNode('dependency')
constraintLayoutDependencyNode.appendNode('groupId', 'androidx.constraintlayout')
constraintLayoutDependencyNode.appendNode('artifactId', 'constraintlayout')
constraintLayoutDependencyNode.appendNode('version', "1.1.3")
}
}
}
}
repositories {
maven {
name = "sonatype"
url = version.endsWith('SNAPSHOT') ? "https://oss.sonatype.org/content/repositories/snapshots/" : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}
ext."signing.gnupg.executable"="gpg"
ext."signing.gnupg.keyName"=System.getenv("GPG_KEY_ID")
ext."signing.gnupg.passphrase"=System.getenv("GPG_PASSPHRASE")
signing {
useGpgCmd()
required {
tasks.withType(PublishToMavenRepository).find {
gradle.taskGraph.hasTask it
}
}
sign publishing.publications
}
task platformUnitTestJacocoReport(type: JacocoReport, dependsOn: "testPhoneDebugUnitTest") {
def excludeRegex = ['**/BuildConfig.class']
def debugTree = fileTree(dir: "${project.buildDir}/intermediates/javac/phoneDebug/classes/com/adobe/marketing/mobile", excludes: excludeRegex)
additionalClassDirs.setFrom files([debugTree])
additionalSourceDirs.setFrom files(android.sourceSets.main.java.sourceFiles)
sourceDirectories.setFrom files(android.sourceSets.phone.java.sourceFiles)
executionData "$buildDir/outputs/unit_test_code_coverage/phoneDebugUnitTest/testPhoneDebugUnitTest.exec"
reports {
xml.required = true
csv.required = false
html.required = true
}
}
task platformFunctionalTestJacocoReport(type: JacocoReport, dependsOn: "createPhoneDebugCoverageReport") {
def excludeRegex = ['**/BuildConfig.class']
def debugTree = fileTree(dir: "${project.buildDir}/intermediates/javac/phoneDebug/classes/com/adobe/marketing/mobile", excludes: excludeRegex)
additionalClassDirs.setFrom files([debugTree])
additionalSourceDirs.setFrom files(android.sourceSets.main.java.sourceFiles)
sourceDirectories.setFrom files(android.sourceSets.phone.java.sourceFiles)
executionData fileTree(dir: "$buildDir", includes: [
"outputs/code_coverage/phoneDebugAndroidTest/connected/*coverage.ec"
])
reports {
xml.required = true
csv.required = false
html.required = true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinApiVersion"
implementation "com.adobe.marketing.mobile:core:${rootProject.mavenCoreVersion}"
testImplementation 'junit:junit:4.13'
testImplementation 'com.google.code.gson:gson:2.8.5'
testImplementation 'org.mockito:mockito-core:4.5.1'
testImplementation 'org.mockito.kotlin:mockito-kotlin:3.2.0'
testImplementation 'org.mockito:mockito-inline:4.5.1'
testImplementation 'net.sf.kxml:kxml2:2.3.0@jar'
testImplementation 'org.json:json:20171018'
testImplementation 'org.robolectric:robolectric:4.2'
androidTestImplementation "androidx.test:core:1.4.0"
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}