Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,28 @@ android {
}
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
isDebuggable = false
}
}
bundle { language { enableSplit = false } }
}

secrets {
defaultPropertiesFileName = "secrets.defaults.properties"
propertiesFileName = "secrets.properties"
}

// workaround for https://github.com/google/ksp/issues/1590
androidComponents {
onVariants(selector().all()) { variant ->
if (variant.name == "fdroidDebug") {
variant.applicationId = "com.geeksville.mesh.fdroid.debug"
variant.applicationId.set("com.geeksville.mesh.fdroid.debug")
}

if (variant.name == "googleDebug") {
variant.applicationId = "com.geeksville.mesh.google.debug"
variant.applicationId.set("com.geeksville.mesh.google.debug")
}
}
onVariants(selector().withBuildType("release")) { variant ->
if (variant.flavorName == "google") {

if (variant.name == "googleRelease") {
val variantNameCapped = variant.name.replaceFirstChar { it.uppercase() }
val minifyTaskName = "minify${variantNameCapped}WithR8"
val uploadTaskName = "uploadMapping$variantNameCapped"
Expand Down Expand Up @@ -276,20 +274,22 @@ tasks.configureEach {

dokka {
moduleName.set("Meshtastic App")
dokkaSourceSets.main {
sourceLink {
enableJdkDocumentationLink.set(true)
enableKotlinStdLibDocumentationLink.set(true)
enableJdkDocumentationLink.set(true)
reportUndocumented.set(true)
localDirectory.set(file("src/main/java"))
remoteUrl("https://github.com/geeksville/Meshtastic-Android/app/src/main/java")
remoteLineSuffix.set("#L")
dokkaSourceSets.configureEach {
if (this.name == "main") {
sourceLink {
enableJdkDocumentationLink.set(true)
enableKotlinStdLibDocumentationLink.set(true)
enableJdkDocumentationLink.set(true)
reportUndocumented.set(true)
localDirectory.set(file("src/main/java"))
remoteUrl("https://github.com/geeksville/Meshtastic-Android/app/src/main/java")
remoteLineSuffix.set("#L")
}
}
dokkaPublications.html { suppressInheritedMembers.set(true) }
dokkaGeneratorIsolation = ProcessIsolation {
// Configures heap size
maxHeapSize = "6g"
}
}
dokkaPublications.html { suppressInheritedMembers.set(true) }
dokkaGeneratorIsolation = ProcessIsolation {
// Configures heap size
maxHeapSize = "6g"
}
}
3 changes: 3 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@
# Our app is opensource no need to obsfucate
-dontobfuscate
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable

# Fix for D8 warning: The companion object Companion could not be found in class com.google.android.gms.internal.location.zze
-keep class com.google.android.gms.internal.location.zze { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import org.gradle.kotlin.dsl.getByType
class AndroidApplicationComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(plugin = "com.android.application")
apply(plugin = "org.jetbrains.kotlin.plugin.compose")

val extension = extensions.getByType<ApplicationExtension>()
configureAndroidCompose(extension)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,26 @@

import com.android.build.api.dsl.ApplicationExtension
import com.geeksville.mesh.buildlogic.configureKotlinAndroid
import com.geeksville.mesh.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies

class AndroidApplicationConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {

apply(plugin = "com.android.application")
apply(plugin = "org.jetbrains.kotlin.android")
apply(plugin = "meshtastic.android.lint")
apply(plugin = "meshtastic.detekt")
apply(plugin = "meshtastic.spotless")
apply(plugin = "com.autonomousapps.dependency-analysis")

extensions.configure<ApplicationExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = 36
testOptions.animationsDisabled = true

defaultConfig {
targetSdk = 36
testInstrumentationRunner = "com.geeksville.mesh.TestRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import org.gradle.kotlin.dsl.getByType
class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(plugin = "com.android.library")
apply(plugin = "org.jetbrains.kotlin.plugin.compose")

val extension = extensions.getByType<LibraryExtension>()
configureAndroidCompose(extension)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,22 @@ import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.geeksville.mesh.buildlogic.configureFlavors
import com.geeksville.mesh.buildlogic.configureKotlinAndroid
import com.geeksville.mesh.buildlogic.disableUnnecessaryAndroidTests
import com.geeksville.mesh.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies

class AndroidLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(plugin = "com.android.library")
apply(plugin = "org.jetbrains.kotlin.android")
apply(plugin = "meshtastic.android.lint")
apply(plugin = "meshtastic.detekt")
apply(plugin = "meshtastic.spotless")
apply(plugin = "com.autonomousapps.dependency-analysis")

extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
testOptions.targetSdk = 36
lint.targetSdk = 36
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testOptions.animationsDisabled = true
configureFlavors(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.geeksville.mesh.buildlogic.configureDetekt
import com.geeksville.mesh.buildlogic.configureKotlinJvm
import com.geeksville.mesh.buildlogic.libs
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.gradle.api.Plugin
Expand All @@ -10,7 +9,6 @@ import org.gradle.kotlin.dsl.getByType
class DetektConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
configureKotlinJvm()
apply(plugin = libs.findPlugin("detekt").get().get().pluginId)
val extension = extensions.getByType<DetektExtension>()
configureDetekt(extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import com.android.build.api.dsl.androidLibrary
import com.android.build.api.dsl.KotlinMultiplatformAndroidLibraryTarget
import com.geeksville.mesh.buildlogic.configProperties
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import java.io.FileInputStream
import java.util.Properties

class KmpLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
Expand All @@ -34,16 +34,9 @@ class KmpLibraryConventionPlugin : Plugin<Project> {
apply(plugin = "meshtastic.spotless")
apply(plugin = "com.autonomousapps.dependency-analysis")

val configPropertiesFile = rootProject.file("config.properties")
val configProperties = Properties()

if (configPropertiesFile.exists()) {
FileInputStream(configPropertiesFile).use { configProperties.load(it) }
}

extensions.configure<KotlinMultiplatformExtension> {
@Suppress("UnstableApiUsage")
androidLibrary {
// Use dynamic configuration for 'android' block to avoid resolution issues
(this as ExtensionAware).extensions.configure<KotlinMultiplatformAndroidLibraryTarget>("android") {
compileSdk = configProperties.getProperty("COMPILE_SDK").toInt()
minSdk = configProperties.getProperty("MIN_SDK").toInt()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import com.geeksville.mesh.buildlogic.configureKotlinJvm
import com.geeksville.mesh.buildlogic.configureSpotless
import com.geeksville.mesh.buildlogic.libs
import org.gradle.api.Plugin
Expand All @@ -10,7 +9,6 @@ import org.gradle.kotlin.dsl.getByType
class SpotlessConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
configureKotlinJvm()
apply(plugin = libs.findPlugin("spotless").get().get().pluginId)
val extension = extensions.getByType<SpotlessExtension>()
configureSpotless(extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

package com.geeksville.mesh.buildlogic

import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.configure
Expand All @@ -28,24 +30,28 @@ import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginE
* Configure Compose-specific options
*/
internal fun Project.configureAndroidCompose(
commonExtension: CommonExtension<*, *, *, *, *, *>,
commonExtension: CommonExtension,
) {
commonExtension.apply {
(commonExtension as? ApplicationExtension)?.apply {
buildFeatures {
compose = true
}

dependencies {
val bom = libs.findLibrary("androidx-compose-bom").get()
"implementation"(platform(bom))
"androidTestImplementation"(platform(bom))
"implementation"(libs.findLibrary("androidx-compose-ui-tooling").get())
"implementation"(libs.findLibrary("androidx-compose-runtime").get())
"runtimeOnly"(libs.findLibrary("androidx-compose-runtime-tracing").get())
"debugImplementation"(libs.findLibrary("androidx-compose-ui-tooling").get())
}
(commonExtension as? LibraryExtension)?.apply {
buildFeatures {
compose = true
}
}

dependencies {
val bom = libs.findLibrary("androidx-compose-bom").get()
"implementation"(platform(bom))
"androidTestImplementation"(platform(bom))
"implementation"(libs.findLibrary("androidx-compose-runtime").get())
"runtimeOnly"(libs.findLibrary("androidx-compose-runtime-tracing").get())
"debugImplementation"(libs.findLibrary("androidx-compose-ui-tooling").get())
}

extensions.configure<ComposeCompilerGradlePluginExtension> {
fun Provider<String>.onlyIfTrue() = flatMap { provider { it.takeIf(String::toBoolean) } }
fun Provider<*>.relativeToRootProject(dir: String) = map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

package com.geeksville.mesh.buildlogic

import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
Expand All @@ -35,15 +37,36 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
* Configure base Kotlin with Android options
*/
internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *, *, *>,
commonExtension: CommonExtension,
) {
commonExtension.apply {
compileSdk = 36
val compileSdk = configProperties.getProperty("COMPILE_SDK").toInt()
val minSdk = configProperties.getProperty("MIN_SDK").toInt()
val targetSdk = configProperties.getProperty("TARGET_SDK").toInt()

(commonExtension as? ApplicationExtension)?.apply {
this.compileSdk = compileSdk
defaultConfig {
minSdk = 26
this.minSdk = minSdk
this.targetSdk = targetSdk
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
isCoreLibraryDesugaringEnabled = true
}
}

(commonExtension as? LibraryExtension)?.apply {
this.compileSdk = compileSdk
defaultConfig {
this.minSdk = minSdk
}
testOptions {
this.targetSdk = targetSdk
}
lint {
this.targetSdk = targetSdk
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package com.geeksville.mesh.buildlogic

import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.ApplicationProductFlavor
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.dsl.ProductFlavor

@Suppress("EnumEntryName")
Expand All @@ -29,15 +29,15 @@ enum class FlavorDimension {

@Suppress("EnumEntryName")
enum class MeshtasticFlavor(val dimension: FlavorDimension, val default: Boolean = false) {
fdroid(FlavorDimension.marketplace, ),
fdroid(FlavorDimension.marketplace),
google(FlavorDimension.marketplace, default = true),
}

fun configureFlavors(
commonExtension: CommonExtension<*, *, *, *, *, *>,
commonExtension: CommonExtension,
flavorConfigurationBlock: ProductFlavor.(flavor: MeshtasticFlavor) -> Unit = {},
) {
commonExtension.apply {
(commonExtension as? ApplicationExtension)?.apply {
FlavorDimension.entries.forEach { flavorDimension ->
flavorDimensions += flavorDimension.name
}
Expand All @@ -47,14 +47,26 @@ fun configureFlavors(
register(meshtasticFlavor.name) {
dimension = meshtasticFlavor.dimension.name
flavorConfigurationBlock(this, meshtasticFlavor)
if (this@apply is ApplicationExtension && this is ApplicationProductFlavor) {
if (meshtasticFlavor.default) {
isDefault = true
}
if (meshtasticFlavor.default) {
isDefault = true
}
}
}
}
}
}

(commonExtension as? LibraryExtension)?.apply {
FlavorDimension.entries.forEach { flavorDimension ->
flavorDimensions += flavorDimension.name
}

productFlavors {
MeshtasticFlavor.entries.forEach { meshtasticFlavor ->
register(meshtasticFlavor.name) {
dimension = meshtasticFlavor.dimension.name
flavorConfigurationBlock(this, meshtasticFlavor)
}
}
}
}
}
Loading