262 lines
7.9 KiB
Kotlin
262 lines
7.9 KiB
Kotlin
plugins {
|
|
id("com.android.library")
|
|
alias(libs.plugins.kotlinter)
|
|
alias(libs.plugins.dokka)
|
|
id("maplibre.download-vulkan-validation")
|
|
id("maplibre.gradle-checkstyle")
|
|
id("maplibre.gradle-dependencies-graph")
|
|
id("maplibre.android-nitpick")
|
|
id("maplibre.gradle-publish")
|
|
id("maplibre.artifact-settings")
|
|
id("org.maplibre.ccache-plugin")
|
|
}
|
|
|
|
dependencies {
|
|
lintChecks(project(":MapLibreAndroidLint"))
|
|
api(libs.maplibreJavaGeoJSON)
|
|
api(libs.maplibreGestures)
|
|
|
|
implementation(libs.maplibreJavaTurf)
|
|
implementation(libs.supportAnnotations)
|
|
implementation(libs.supportFragmentV4)
|
|
implementation(libs.okhttp3)
|
|
implementation(libs.timber)
|
|
implementation(libs.interpolator)
|
|
implementation(libs.kotlinxCoroutinesCore)
|
|
|
|
testImplementation(libs.junit)
|
|
testImplementation(libs.mockito)
|
|
testImplementation(libs.mockk)
|
|
testImplementation(libs.robolectric)
|
|
testImplementation(libs.commonsIO)
|
|
testImplementation(libs.assertjcore)
|
|
|
|
androidTestImplementation(libs.testRunner)
|
|
androidTestImplementation(libs.testRules)
|
|
}
|
|
|
|
dokka {
|
|
moduleName.set("MapLibre Native Android")
|
|
val dokkaVariantName = "openglRelease"
|
|
|
|
dokkaSourceSets {
|
|
configureEach {
|
|
suppress.set(name != dokkaVariantName)
|
|
includes.from("Module.md")
|
|
|
|
sourceLink {
|
|
remoteUrl.set(uri("https://github.com/maplibre/maplibre-native/tree/main/platform/android/"))
|
|
localDirectory.set(rootDir)
|
|
}
|
|
|
|
// TODO add externalDocumentationLinks when these get dokka or javadocs:
|
|
// - https://github.com/maplibre/maplibre-java
|
|
// - https://github.com/maplibre/maplibre-gestures-android
|
|
}
|
|
}
|
|
}
|
|
|
|
android {
|
|
ndkVersion = Versions.ndkVersion
|
|
|
|
defaultConfig {
|
|
compileSdk = 34
|
|
minSdk = 23
|
|
buildConfigField("String", "GIT_REVISION_SHORT", "\"${getGitRevision()}\"")
|
|
buildConfigField("String", "GIT_REVISION", "\"${getGitRevision(false)}\"")
|
|
buildConfigField(
|
|
"String",
|
|
"MAPLIBRE_VERSION_STRING",
|
|
"\"MapLibre Android/${project.extra["versionName"]}\""
|
|
)
|
|
consumerProguardFiles("proguard-rules.pro")
|
|
}
|
|
|
|
flavorDimensions += "renderer"
|
|
productFlavors {
|
|
create("opengl") {
|
|
dimension = "renderer"
|
|
externalNativeBuild {
|
|
cmake {
|
|
arguments("-DMLN_WITH_OPENGL=ON")
|
|
}
|
|
}
|
|
}
|
|
create("vulkan") {
|
|
dimension = "renderer"
|
|
externalNativeBuild {
|
|
cmake {
|
|
arguments("-DMLN_WITH_VULKAN=ON")
|
|
}
|
|
}
|
|
}
|
|
create("webgpuDawn") {
|
|
dimension = "renderer"
|
|
externalNativeBuild {
|
|
cmake {
|
|
arguments("-DMLN_WITH_WEBGPU=ON", "-DMLN_WEBGPU_IMPL_DAWN=ON")
|
|
}
|
|
}
|
|
}
|
|
create("webgpuWgpu") {
|
|
dimension = "renderer"
|
|
ndk {
|
|
abiFilters += "arm64-v8a"
|
|
}
|
|
externalNativeBuild {
|
|
cmake {
|
|
arguments("-DMLN_WITH_WEBGPU=ON", "-DMLN_WEBGPU_IMPL_WGPU=ON")
|
|
}
|
|
}
|
|
}
|
|
create("multiBackend") {
|
|
dimension = "renderer"
|
|
externalNativeBuild {
|
|
cmake {
|
|
arguments("-DMLN_ANDROID_MULTI_BACKEND=ON")
|
|
targets("maplibre-opengl", "maplibre-vulkan")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
getByName("opengl") {
|
|
java.srcDirs("src/opengl/java/", "src/sharedRenderer/opengl/java/")
|
|
}
|
|
getByName("vulkan") {
|
|
java.srcDirs("src/vulkan/java/", "src/sharedRenderer/vulkan/java/")
|
|
}
|
|
listOf("webgpuDawn", "webgpuWgpu").forEach {
|
|
getByName(it) {
|
|
java.srcDirs("src/vulkan/java/", "src/sharedRenderer/vulkan/java/")
|
|
manifest.srcFile("src/vulkan/AndroidManifest.xml")
|
|
}
|
|
}
|
|
getByName("multiBackend") {
|
|
java.srcDirs(
|
|
"src/multiBackend/java/",
|
|
"src/sharedRenderer/opengl/java/",
|
|
"src/sharedRenderer/vulkan/java/"
|
|
)
|
|
manifest.srcFile("src/multiBackend/AndroidManifest.xml")
|
|
}
|
|
}
|
|
|
|
// Build native libraries
|
|
val nativeTargets = mutableListOf("maplibre")
|
|
if (project.hasProperty("mapbox.with_test")) {
|
|
nativeTargets.add("mbgl-test")
|
|
}
|
|
if (project.hasProperty("mapbox.with_benchmark")) {
|
|
nativeTargets.add("mbgl-benchmark")
|
|
}
|
|
nativeBuild(nativeTargets)
|
|
|
|
// Avoid naming conflicts, force usage of prefix
|
|
resourcePrefix = "maplibre_"
|
|
|
|
sourceSets {
|
|
getByName("main") {
|
|
res.srcDirs("src/main/res-public")
|
|
}
|
|
}
|
|
|
|
testOptions {
|
|
unitTests {
|
|
isReturnDefaultValues = true
|
|
|
|
// Robolectric 4.0 required config
|
|
// http://robolectric.org/migrating/#migrating-to-40
|
|
isIncludeAndroidResources = true
|
|
}
|
|
targetSdk = 33
|
|
}
|
|
|
|
buildTypes {
|
|
debug {
|
|
isJniDebuggable = true
|
|
enableUnitTestCoverage = false
|
|
enableAndroidTestCoverage = false
|
|
}
|
|
}
|
|
|
|
namespace = "org.maplibre.android"
|
|
|
|
lint {
|
|
checkAllWarnings = true
|
|
disable += listOf(
|
|
"MissingTranslation",
|
|
"TypographyQuotes",
|
|
"ObsoleteLintCustomCheck",
|
|
"MissingPermission",
|
|
"WrongThreadInterprocedural"
|
|
)
|
|
warningsAsErrors = false
|
|
targetSdk = 33
|
|
}
|
|
|
|
buildFeatures {
|
|
buildConfig = true
|
|
prefabPublishing = project.findProperty("maplibre.abis") != "none"
|
|
}
|
|
|
|
prefab {
|
|
create("maplibre") {
|
|
headers = "../prefab-headers"
|
|
headerOnly = true
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_11
|
|
targetCompatibility = JavaVersion.VERSION_11
|
|
}
|
|
|
|
}
|
|
|
|
fun getGitRevision(shortRev: Boolean = true): String {
|
|
val cmd = if (shortRev) "git rev-parse --short HEAD" else "git rev-parse HEAD"
|
|
val proc = Runtime.getRuntime().exec(cmd)
|
|
return proc.inputStream.bufferedReader().readText().trim()
|
|
}
|
|
|
|
val syncPrefabHeaders by tasks.registering(Sync::class) {
|
|
val nativeRoot = rootProject.rootDir.resolve("../..")
|
|
from(nativeRoot.resolve("include")) {
|
|
include("mbgl/style/layers/custom_layer_host.hpp")
|
|
include("mbgl/style/layers/custom_layer_init_parameters.hpp")
|
|
include("mbgl/style/layers/custom_layer_render_parameters.hpp")
|
|
include("mbgl/style/layers/vulkan/custom_layer_init_parameters.hpp")
|
|
include("mbgl/style/layers/vulkan/custom_layer_render_parameters.hpp")
|
|
}
|
|
into(project.rootDir.resolve("prefab-headers"))
|
|
}
|
|
|
|
tasks.configureEach {
|
|
if (name == "syncPrefabHeaders") return@configureEach
|
|
if (name.contains("Prefab", ignoreCase = true) || name.contains("bundleLibRuntimeTo", ignoreCase = true)) {
|
|
dependsOn(syncPrefabHeaders)
|
|
}
|
|
}
|
|
|
|
// AGP 9.1.1 still adds the native build output to the AAR even when the Prefab module is
|
|
// declared header-only. Keep the header-only metadata and omit that redundant unstripped copy.
|
|
tasks.withType<org.gradle.api.tasks.bundling.Zip>().configureEach {
|
|
if (name.startsWith("bundle") && name.endsWith("Aar")) {
|
|
// The Prefab artifact is added under a `prefab/` destination by a nested copy spec,
|
|
// so its paths are still relative to the Prefab root when exclusions are evaluated.
|
|
exclude("modules/maplibre/libs/**")
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
getByName("implementation") {
|
|
exclude(group = "commons-logging", module = "commons-logging")
|
|
exclude(group = "commons-collections", module = "commons-collections")
|
|
}
|
|
}
|
|
|
|
// intentionally disabled
|
|
// apply(plugin = "maplibre.jacoco-report")
|