-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
252 lines (222 loc) · 8.51 KB
/
build.gradle.kts
File metadata and controls
252 lines (222 loc) · 8.51 KB
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
import java.net.URI
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
id(libs.plugins.maven.publish.get().pluginId)
id(libs.plugins.signing.get().pluginId)
alias(libs.plugins.dokka)
alias(libs.plugins.compose.compiler)
id(libs.plugins.kotlin.parcelize.get().pluginId)
id(libs.plugins.jacoco.get().pluginId)
}
/**
* IS_SNAPSHOT_RELEASE property will be automatically added to the root gradle.properties file by the CI pipeline, depending on the GitHub branch.
* A snapshot release is generated for every pull request merged or commit made into an epic branch.
*/
val isSnapshotRelease = findProperty("IS_SNAPSHOT_RELEASE") == "true"
version =
if (isSnapshotRelease) "${findProperty("LIBRARY_VERSION")}-SNAPSHOT" else "${findProperty("LIBRARY_VERSION")}"
android {
namespace = "com.what3words.map.components.compose"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
buildConfigField("String", "LIBRARY_VERSION", "\"${findProperty("LIBRARY_VERSION")}\"")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
debug {
enableUnitTestCoverage = true
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildFeatures {
compose = true
buildConfig = true
}
kotlinOptions {
jvmTarget = libs.versions.jvmTarget.get()
}
publishing {
singleVariant("release") {
withSourcesJar()
}
}
}
jacoco {
toolVersion = libs.versions.jacocoVersion.get()
}
tasks.register<JacocoReport>("jacocoTestReport") {
dependsOn(tasks.withType<Test>().named("testDebugUnitTest"))
reports {
xml.required.set(true)
html.required.set(true)
}
val fileFilter = listOf(
"**/R.class",
"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/buttons/**",
"**/providers/**",
"**/utils/**",
"**/models/**",
"**/MapProvider*.*",
"**/state/camera/**",
"**/W3WMapComponent*.*",
"**/W3WMapDefaults*.*",
)
val javaTree = fileTree("${buildDir}/intermediates/javac/debug") {
exclude(fileFilter)
}
val kotlinTree = fileTree("${buildDir}/tmp/kotlin-classes/debug") {
exclude(fileFilter)
}
sourceDirectories.setFrom(files("${project.projectDir}/src/main/java", "${project.projectDir}/src/main/kotlin"))
classDirectories.setFrom(files(javaTree, kotlinTree))
executionData.setFrom(fileTree("${buildDir}/outputs/unit_test_code_coverage/debugUnitTest").apply {
include("testDebugUnitTest.exec")
})
}
tasks.register("checkSnapshotDependencies") {
doLast {
val snapshotDependencies = allprojects.flatMap { project ->
project.configurations
.asSequence()
.filter { it.isCanBeResolved }
.flatMap { it.allDependencies }
.filter { it.version?.contains("SNAPSHOT", ignoreCase = true) == true }
.map { "${project.name}:${it.group}:${it.name}:${it.version}" }
.distinct()
.toList()
}
if (snapshotDependencies.isNotEmpty()) {
snapshotDependencies.forEach { println("SNAPSHOT dependency found: $it") }
throw GradleException("SNAPSHOT dependencies found.")
} else {
println("No SNAPSHOT dependencies found.")
}
}
}
dependencies {
// Material
implementation(libs.material)
implementation(libs.accompanist.permissions)
// what3words
api(libs.what3words.api.wrapper)
api(libs.what3words.designLibrary)
// Google maps
compileOnly(libs.googlemap.playservice)
compileOnly(libs.googlemap.utils)
testImplementation(libs.googlemap.playservice)
implementation(libs.googlemap.compose)
// Mapbox
implementation(libs.mapbox.v11)
implementation(libs.extension.mapbox.compose)
// kotlin
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.coroutines.android)
testImplementation(libs.kotlinx.coroutines.test)
api(libs.kotlinx.collections.immutable)
// Compose
implementation(platform(libs.androidx.compose.bom))
implementation(libs.compose.material3)
implementation(libs.compose.ui)
implementation(libs.compose.material.extended.icons)
implementation(libs.compose.ui.viewbinding)
debugImplementation(libs.compose.ui.tooling)
implementation(libs.compose.ui.tooling.preview)
// Testing
testImplementation(libs.junit4)
testImplementation(libs.androidx.core)
testImplementation(libs.truth)
testImplementation(libs.mockk)
testImplementation(libs.androidx.core.testing)
}
//region publishing
val ossrhUsername = findProperty("OSSRH_USERNAME") as String?
val ossrhPassword = findProperty("OSSRH_PASSWORD") as String?
val signingKey = findProperty("SIGNING_KEY") as String?
val signingKeyPwd = findProperty("SIGNING_KEY_PWD") as String?
publishing {
repositories {
maven {
name = "sonatype"
val releasesRepoUrl =
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl =
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = if (version.toString()
.endsWith("SNAPSHOT")
) URI.create(snapshotsRepoUrl) else URI.create(releasesRepoUrl)
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
publications {
create<MavenPublication>("Maven") {
artifactId = "w3w-android-map-components-compose"
groupId = "com.what3words"
version = project.version.toString()
afterEvaluate {
from(components["release"])
}
}
withType(MavenPublication::class.java) {
val publicationName = name
val dokkaJar =
project.tasks.register("${publicationName}DokkaJar", Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Kotlin docs with Dokka into a Javadoc jar"
archiveClassifier.set("javadoc")
from(tasks.named("dokkaHtml"))
// Each archive name should be distinct, to avoid implicit dependency issues.
// We use the same format as the sources Jar tasks.
// https://youtrack.jetbrains.com/issue/KT-46466
archiveBaseName.set("${archiveBaseName.get()}-$publicationName")
}
artifact(dokkaJar)
pom {
name.set("w3w-android-map-components-compose")
description.set("Android library to integrate what3words with different map providers.")
url.set("https://github.com/what3words/w3w-android-map-components")
licenses {
license {
name.set("The MIT License (MIT)")
url.set("https://github.com/what3words/w3w-android-map-components/blob/master/LICENSE")
}
}
developers {
developer {
id.set("what3words")
name.set("what3words")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/what3words/w3w-android-map-components.git")
developerConnection.set("scm:git:ssh://[email protected]:what3words/w3w-android-map-components.git")
url.set("https://github.com/what3words/w3w-android-map-components")
}
}
}
}
}
}
signing {
useInMemoryPgpKeys(signingKey, signingKeyPwd)
sign(publishing.publications)
}
//endregion