-
Notifications
You must be signed in to change notification settings - Fork 119
/
build.gradle.kts
204 lines (176 loc) · 6.62 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
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
/*
* 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 app.cash.licensee.LicenseeExtension
import com.android.build.gradle.LibraryExtension
import kotlinx.validation.ApiValidationExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
google()
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
}
dependencies {
classpath(kotlin("gradle-plugin", version = "1.9.10"))
classpath("com.google.gms:google-services:4.3.15")
classpath("org.jlleitschuh.gradle:ktlint-gradle:11.0.0")
classpath("org.jetbrains.kotlinx:kover:0.6.1")
classpath("app.cash.licensee:licensee-gradle-plugin:1.7.0")
}
}
plugins {
alias(libs.plugins.binary.compatibility.validator)
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.android.library) apply false
}
allprojects {
gradle.projectsEvaluated {
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.apply {
add("-Xlint:all")
//add("-Werror")
}
}
tasks.withType<Test>().configureEach {
minHeapSize = "128m"
maxHeapSize = "4g"
}
}
}
tasks.register<Delete>("clean").configure {
delete(rootProject.buildDir)
}
val internalApiAnnotations = listOf(
"com.amplifyframework.annotations.InternalApiWarning",
"com.amplifyframework.annotations.InternalAmplifyApi",
"com.amplifyframework.annotations.AmplifyFlutterApi"
)
subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
android.set(true)
}
apply(plugin = "app.cash.licensee")
afterEvaluate {
configure<LicenseeExtension> {
allow("Apache-2.0")
allow("MIT")
allow("BSD-2-Clause")
allow("CC0-1.0")
allowUrl("https://developer.android.com/studio/terms.html")
allowDependency("net.zetetic", "android-database-sqlcipher", "4.5.4") {
because("BSD style License")
}
allowDependency("org.jetbrains", "annotations", "16.0.1") {
because("Apache-2.0, but typo in license URL fixed in newer versions")
}
allowDependency("org.mockito", "mockito-core", "3.9.0") {
because("MIT license")
}
allowDependency("junit", "junit", "4.13.2") {
because("Test Dependency")
}
allowUrl("https://raw.githubusercontent.com/apollographql/apollo-kotlin/main/LICENSE") {
because("MIT license")
}
}
configureAndroid()
apply(from = rootProject.file("kover.gradle"))
}
tasks.withType<KotlinCompile> {
kotlinOptions {
internalApiAnnotations.forEach {
freeCompilerArgs += "-opt-in=$it"
}
}
}
pluginManager.withPlugin("kotlin-android") {
configure<KotlinProjectExtension> {
jvmToolchain(17)
}
}
}
@Suppress("ExpiredTargetSdkVersion")
fun Project.configureAndroid() {
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")
}
pluginManager.withPlugin("com.android.library") {
val sdkVersionName = findProperty("VERSION_NAME") ?: rootProject.findProperty("VERSION_NAME")
configure<LibraryExtension> {
buildToolsVersion = "30.0.3"
compileSdk = 34
buildFeatures {
// Allow specifying custom buildConfig fields
buildConfig = true
}
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
}
// 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.addAll(
listOf(
"META-INF/DEPENDENCIES",
"META-INF/LICENSE.md",
"META-INF/LICENSE-notice.md"
)
)
}
publishing {
singleVariant("release") {
withSourcesJar()
}
}
}
dependencies {
add("coreLibraryDesugaring", libs.android.desugartools)
}
}
}
apply(from = rootProject.file("configuration/instrumentation-tests.gradle"))
configure<ApiValidationExtension> {
// Interfaces marked with an internal API annotation are not part of the public API
nonPublicMarkers.addAll(internalApiAnnotations)
nonPublicMarkers.add("androidx.annotation.VisibleForTesting")
ignoredProjects.addAll(setOf("testutils", "testmodels", "annotations"))
}