Use Kotlin instead of Groovy for Android build configuration (#2902)
This commit is contained in:
committed by
GitHub
parent
1fa7df3331
commit
8d284cf331
@@ -1,186 +0,0 @@
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
|
||||
plugins {
|
||||
alias libs.plugins.kotlinter
|
||||
alias libs.plugins.dokka
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: "com.jaredsburrows.license"
|
||||
apply plugin: 'kotlin-android'
|
||||
apply from: "${rootDir}/gradle/native-build.gradle"
|
||||
|
||||
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
|
||||
|
||||
testImplementation libs.junit
|
||||
testImplementation libs.mockito
|
||||
testImplementation libs.mockk
|
||||
testImplementation libs.robolectric
|
||||
testImplementation libs.commonsIO
|
||||
testImplementation libs.assertjcore
|
||||
|
||||
androidTestImplementation libs.testRunner
|
||||
androidTestImplementation libs.testRules
|
||||
}
|
||||
|
||||
tasks.withType(DokkaTask.class) {
|
||||
moduleName.set("MapLibre Native Android")
|
||||
|
||||
dokkaSourceSets {
|
||||
configureEach {
|
||||
includes.from("Module.md")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
compileSdk 34
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
buildConfigField "String", "GIT_REVISION_SHORT", String.format("\"%s\"", getGitRevision())
|
||||
buildConfigField "String", "GIT_REVISION", String.format("\"%s\"", getGitRevision(false))
|
||||
buildConfigField "String", "MAPLIBRE_VERSION_STRING", String.format("\"MapLibre Native/%s\"", project.VERSION_NAME)
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions += "renderer"
|
||||
productFlavors {
|
||||
create("legacy") {
|
||||
dimension = "renderer"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF"
|
||||
}
|
||||
}
|
||||
}
|
||||
create("drawable") {
|
||||
dimension = "renderer"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON"
|
||||
}
|
||||
}
|
||||
}
|
||||
create("vulkan") {
|
||||
dimension = "renderer"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON"
|
||||
arguments "-DMLN_WITH_OPENGL=OFF", "-DMLN_WITH_VULKAN=ON"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
legacy {
|
||||
java.srcDirs += ['src/opengl/java/']
|
||||
}
|
||||
drawable {
|
||||
java.srcDirs += ['src/opengl/java/']
|
||||
}
|
||||
}
|
||||
|
||||
// build native libraries
|
||||
List nativeTargets = ["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 {
|
||||
// limit amount of exposed library resources
|
||||
main.res.srcDirs += 'src/main/res-public'
|
||||
}
|
||||
|
||||
|
||||
testOptions {
|
||||
unitTests {
|
||||
returnDefaultValues true
|
||||
|
||||
// Roboelectric 4.0 required config
|
||||
// http://robolectric.org/migrating/#migrating-to-40
|
||||
includeAndroidResources = true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
testCoverageEnabled false
|
||||
jniDebuggable true
|
||||
debuggable true
|
||||
}
|
||||
}
|
||||
namespace 'org.maplibre.android'
|
||||
lint {
|
||||
checkAllWarnings true
|
||||
disable 'MissingTranslation', 'TypographyQuotes', 'ObsoleteLintCustomCheck', 'MissingPermission', 'WrongThreadInterprocedural'
|
||||
warningsAsErrors false
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = 11
|
||||
targetCompatibility = 11
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
}
|
||||
|
||||
licenseReport {
|
||||
generateHtmlReport = false
|
||||
generateJsonReport = true
|
||||
copyHtmlReportToAssets = false
|
||||
copyJsonReportToAssets = false
|
||||
}
|
||||
|
||||
def static getGitRevision(shortRev = true) {
|
||||
def cmd = shortRev ? "git rev-parse --short HEAD" : "git rev-parse HEAD"
|
||||
def proc = cmd.execute()
|
||||
def ref = proc.text.trim()
|
||||
return ref
|
||||
}
|
||||
|
||||
configurations {
|
||||
all*.exclude group: 'commons-logging', module: 'commons-logging'
|
||||
all*.exclude group: 'commons-collections', module: 'commons-collections'
|
||||
}
|
||||
|
||||
// Download validation layers from
|
||||
// https://github.com/KhronosGroup/Vulkan-ValidationLayers
|
||||
apply from: "${rootDir}/gradle/download-vulkan-validation.gradle"
|
||||
|
||||
apply from: "${rootDir}/gradle/gradle-checkstyle.gradle"
|
||||
apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle"
|
||||
apply from: "${rootDir}/gradle/android-nitpick.gradle"
|
||||
apply from: "${rootDir}/gradle/gradle-publish.gradle"
|
||||
// intentionally disabled
|
||||
// apply from: "${rootDir}/gradle/jacoco-report.gradle"
|
||||
196
platform/android/MapLibreAndroid/build.gradle.kts
Normal file
196
platform/android/MapLibreAndroid/build.gradle.kts
Normal file
@@ -0,0 +1,196 @@
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinter)
|
||||
alias(libs.plugins.dokka)
|
||||
id("com.android.library")
|
||||
id("com.jaredsburrows.license")
|
||||
kotlin("android")
|
||||
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")
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
testImplementation(libs.junit)
|
||||
testImplementation(libs.mockito)
|
||||
testImplementation(libs.mockk)
|
||||
testImplementation(libs.robolectric)
|
||||
testImplementation(libs.commonsIO)
|
||||
testImplementation(libs.assertjcore)
|
||||
|
||||
androidTestImplementation(libs.testRunner)
|
||||
androidTestImplementation(libs.testRules)
|
||||
}
|
||||
|
||||
tasks.withType<DokkaTask> {
|
||||
moduleName.set("MapLibre Native Android")
|
||||
|
||||
dokkaSourceSets {
|
||||
configureEach {
|
||||
includes.from("Module.md")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
compileSdk = 34
|
||||
minSdk = 21
|
||||
targetSdk = 33
|
||||
buildConfigField("String", "GIT_REVISION_SHORT", "\"${getGitRevision()}\"")
|
||||
buildConfigField("String", "GIT_REVISION", "\"${getGitRevision(false)}\"")
|
||||
buildConfigField(
|
||||
"String",
|
||||
"MAPLIBRE_VERSION_STRING",
|
||||
"\"MapLibre Native/${project.property("VERSION_NAME")}\""
|
||||
)
|
||||
consumerProguardFiles("proguard-rules.pro")
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments("-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions += "renderer"
|
||||
productFlavors {
|
||||
create("legacy") {
|
||||
dimension = "renderer"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments("-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF")
|
||||
}
|
||||
}
|
||||
}
|
||||
create("drawable") {
|
||||
dimension = "renderer"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments("-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON")
|
||||
}
|
||||
}
|
||||
}
|
||||
create("vulkan") {
|
||||
dimension = "renderer"
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments("-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON")
|
||||
arguments("-DMLN_WITH_OPENGL=OFF", "-DMLN_WITH_VULKAN=ON")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
getByName("legacy") {
|
||||
java.srcDirs("src/opengl/java/")
|
||||
}
|
||||
getByName("drawable") {
|
||||
java.srcDirs("src/opengl/java/")
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
isTestCoverageEnabled = false
|
||||
isJniDebuggable = true
|
||||
}
|
||||
}
|
||||
|
||||
namespace = "org.maplibre.android"
|
||||
|
||||
lint {
|
||||
checkAllWarnings = true
|
||||
disable += listOf(
|
||||
"MissingTranslation",
|
||||
"TypographyQuotes",
|
||||
"ObsoleteLintCustomCheck",
|
||||
"MissingPermission",
|
||||
"WrongThreadInterprocedural"
|
||||
)
|
||||
warningsAsErrors = false
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
}
|
||||
|
||||
licenseReport {
|
||||
generateHtmlReport = false
|
||||
generateJsonReport = true
|
||||
copyHtmlReportToAssets = false
|
||||
copyJsonReportToAssets = false
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
configurations {
|
||||
getByName("implementation") {
|
||||
exclude(group = "commons-logging", module = "commons-logging")
|
||||
exclude(group = "commons-collections", module = "commons-collections")
|
||||
}
|
||||
}
|
||||
|
||||
apply<DownloadVulkanValidationPlugin>()
|
||||
|
||||
// intentionally disabled
|
||||
// apply(plugin = "maplibre.jacoco-report")
|
||||
Reference in New Issue
Block a user