forked from aws-amplify/amplify-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
176 lines (150 loc) · 5.27 KB
/
build.gradle.kts
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
/*
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/
import com.android.build.gradle.LibraryExtension
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
google()
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath(kotlin("gradle-plugin", version = "1.7.10"))
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.7.10")
classpath("com.google.gms:google-services:4.3.15")
classpath("org.jlleitschuh.gradle:ktlint-gradle:11.0.0")
classpath("org.gradle:test-retry-gradle-plugin:1.4.1")
classpath("org.jetbrains.kotlinx:kover:0.6.1")
}
}
allprojects {
repositories {
maven(url = "https://aws.oss.sonatype.org/content/repositories/snapshots/")
google()
mavenCentral()
}
gradle.projectsEvaluated {
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.apply {
add("-Xlint:all")
add("-Werror")
}
}
tasks.withType<Test>().configureEach {
minHeapSize = "128m"
maxHeapSize = "4g"
}
}
}
apply(plugin = "org.jetbrains.dokka")
tasks.withType<DokkaTask>().configureEach {
outputDirectory.set(rootProject.buildDir)
}
tasks.register<Delete>("clean").configure {
delete(rootProject.buildDir)
}
val optInAnnotations = listOf(
"com.amplifyframework.annotations.InternalApiWarning",
"com.amplifyframework.annotations.InternalAmplifyApi"
)
subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
android.set(true)
}
afterEvaluate {
configureAndroid()
apply(from = "../kover.gradle")
}
if (!name.contains("test")) {
apply(plugin = "org.jetbrains.dokka")
tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets {
configureEach {
includeNonPublic.set(false)
skipEmptyPackages.set(true)
skipDeprecated.set(true)
reportUndocumented.set(true)
jdkVersion.set(8)
}
}
}
}
apply(plugin = "org.gradle.test-retry")
tasks.withType<Test>().configureEach {
retry {
maxRetries.set(1)
maxFailures.set(100)
failOnPassedAfterRetry.set(true)
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
optInAnnotations.forEach {
freeCompilerArgs += "-opt-in=$it"
}
}
}
}
@Suppress("ExpiredTargetSdkVersion")
fun Project.configureAndroid() {
val sdkVersionName = findProperty("VERSION_NAME") ?: rootProject.findProperty("VERSION_NAME")
if (hasProperty("signingKeyId")) {
println("Getting signing info from protected source.")
extra["signing.keyId"] = findProperty("signingKeyId")
extra["signing.password"] = findProperty("signingPassword")
extra["signing.inMemoryKey"] = findProperty("signingInMemoryKey")
}
configure<LibraryExtension> {
buildToolsVersion = "30.0.3"
compileSdk = 32
defaultConfig {
minSdk = 24
targetSdk = 30
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments += "clearPackageData" to "true"
consumerProguardFiles += rootProject.file("configuration/consumer-rules.pro")
testOptions {
animationsDisabled = true
unitTests {
isIncludeAndroidResources = true
}
}
buildConfigField("String", "VERSION_NAME", "\"$sdkVersionName\"")
}
lint {
warningsAsErrors = true
abortOnError = true
enable += listOf("UnusedResources", "NewerVersionAvailable")
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// Needed when running integration tests. The oauth2 library uses relies on two
// dependencies (Apache's httpcore and httpclient), both of which include
// META-INF/DEPENDENCIES. Tried a couple other options to no avail.
packagingOptions {
resources.excludes.add("META-INF/DEPENDENCIES")
}
}
dependencies {
add("coreLibraryDesugaring", libs.android.desugartools)
}
}
apply(from = rootProject.file("configuration/instrumentation-tests.gradle"))