-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
192 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
import org.jetbrains.dokka.gradle.DokkaTask
plugins {
id("com.android.library")
kotlin("android")
id("com.jaredsburrows.license")
id("org.jetbrains.dokka")
// FIXME https://mapbox.atlassian.net/browse/MAPSAND-794
//id("com.mapbox.android.sdk.versions")
id("io.gitlab.arturbosch.detekt").version(Versions.detekt)
}
android {
compileSdk = AndroidVersions.compileSdkVersion
defaultConfig {
minSdk = AndroidVersions.minSdkVersion
targetSdk = AndroidVersions.targetSdkVersion
consumerProguardFiles("proguard-rules.pro")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments(mapOf("clearPackageData" to "true"))
if (project.hasProperty("android.injected.invoked.from.ide")) {
buildConfigField("boolean", "RUN_FROM_IDE", "true")
} else {
buildConfigField("boolean", "RUN_FROM_IDE", "false")
}
}
testOptions {
unitTests.apply {
isIncludeAndroidResources = true
}
animationsDisabled = true
if (!project.hasProperty("android.injected.invoked.from.ide")) {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
flavorDimensions.add("version")
productFlavors {
val private by creating {
dimension = "version"
}
val public by creating {
dimension = "version"
isDefault = true
}
}
sourceSets {
// limit amount of exposed library resources
getByName("public").res.srcDirs("src/public/res-public")
getByName("private").res.srcDirs("src/private/res-public")
}
}
val buildFromSource: String by project
dependencies {
api(Dependencies.mapboxBase)
if (buildFromSource.toBoolean()) {
api(project(":okhttp"))
} else {
api(Dependencies.mapboxOkHttp)
}
implementation(Dependencies.mapboxAnnotations)
api(project(":sdk-base"))
implementation(project(":module-telemetry"))
api(project(":extension-style"))
api(project(":plugin-logo"))
api(project(":plugin-compass"))
api(project(":plugin-gestures"))
api(project(":plugin-attribution"))
api(project(":plugin-locationcomponent"))
api(project(":plugin-animation"))
api(project(":plugin-scalebar"))
api(project(":plugin-overlay"))
api(project(":plugin-annotation"))
api(project(":extension-localization"))
api(project(":plugin-lifecycle"))
api(project(":plugin-viewport"))
compileOnly(Dependencies.asyncInflater)
implementation(Dependencies.kotlin)
implementation(Dependencies.androidxCoreKtx)
implementation(Dependencies.androidxAnnotations)
testImplementation(Dependencies.junit)
testImplementation(Dependencies.mockk)
testImplementation(Dependencies.androidxTestCore)
testImplementation(Dependencies.robolectric)
testImplementation(Dependencies.robolectricEgl)
testImplementation(Dependencies.asyncInflater)
testImplementation(Dependencies.equalsVerifier)
testImplementation(Dependencies.androidxTestJUnit)
debugImplementation(Dependencies.androidxAppCompat)
androidTestImplementation(Dependencies.androidxTestRunner)
androidTestImplementation(Dependencies.androidxTestJUnit)
androidTestImplementation(Dependencies.androidxRules)
androidTestImplementation(Dependencies.androidxJUnitTestRules)
androidTestImplementation(Dependencies.androidxEspresso)
androidTestImplementation(Dependencies.androidxUiAutomator)
androidTestImplementation(Dependencies.coroutines)
androidTestUtil(Dependencies.androidxOrchestrator)
detektPlugins(Dependencies.detektFormatting)
}
// let's register different Dokka Javadoc tasks per flavor
android.productFlavors.all {
val flavor = name
tasks.register("${flavor}ReleaseDokkaJavadoc", DokkaTask::class.java) {
// We want to generate Javadoc so we copy the `dokkaJavadoc` task plugins/runtime
val dokkaJavadocTask = tasks.findByName("dokkaJavadoc") as DokkaTask
plugins.setExtendsFrom(listOf(dokkaJavadocTask.plugins))
runtime.setExtendsFrom(listOf(dokkaJavadocTask.runtime))
dokkaSourceSets {
// To avoid undocumented inherited methods/classes we need to join all the source roots
// related to the flavor release variant into one source set (`${flavor}Release`).
named("${flavor}Release") {
listOf("java", "kotlin").forEach { lang ->
sourceRoots.from(
file("src/main/$lang"),
file("src/${flavor}/$lang"),
file("src/${flavor}Release/$lang"),
)
}
}
configureEach {
// Make sure we disable all the source sets not related to this flavour release variant.
// Otherwise, we would have duplicate classes or undocumented entries.
if (name != "${flavor}Release") {
suppress.set(true)
}
reportUndocumented.set(true)
failOnWarning.set(true)
}
}
}
tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets {
named("${flavor}Release") {
val upstreamApiDocFile = rootProject.file("upstream-api-doc-list.txt")
if (upstreamApiDocFile.exists()) {
// We include the files in "upstream-api-doc-list.txt" which might not have docs
reportUndocumented.set(false)
val tmpJavaForDokkaFolder = getAndCreateJavaForDokkaFolder()
upstreamApiDocFile.forEachLine {
if (!it.startsWith("//")) {
val file = file("../../$it")
if (!file.exists()) {
throw GradleException("Unable to add ${file.absolutePath}")
} else if (!file.isDirectory && file.extension == "java") {
// Due to bug https://github.com/Kotlin/dokka/issues/2590 in 1.5.31 we copy the
// individual Java files to a separate folder that will be included as sourceRoot
// We use the full `it` to avoid collisions
file.copyTo(target = tmpJavaForDokkaFolder.resolve(it), overwrite = true)
} else {
sourceRoots.from(file)
}
}
}
// Always add the temporary folder to generate documentation
sourceRoot(tmpJavaForDokkaFolder)
}
}
}
}
}
project.apply {
from("$rootDir/gradle/ktlint.gradle")
from("$rootDir/gradle/lint.gradle")
from("$rootDir/gradle/jacoco.gradle")
from("$rootDir/gradle/sdk-registry.gradle")
from("$rootDir/gradle/track-public-apis.gradle")
from("$rootDir/gradle/detekt.gradle")
from("$rootDir/gradle/dependency-updates.gradle")
}
fun getAndCreateJavaForDokkaFolder() =
buildDir.resolve("dokka/tmp_java_files").also {
if (!it.exists() && !it.mkdirs()) {
throw GradleException("Couldn't create folder $it")
}
}