diff --git a/.gitmodules b/.gitmodules index 8ce701868..9d7b1df30 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +1,5 @@ [submodule "app proto submodule"] - path = app/src/main/proto - url = https://github.com/meshtastic/protobufs.git -[submodule "mesh_service_example proto submodule"] - path = mesh_service_example/src/main/proto + path = core/proto/src/main/proto url = https://github.com/meshtastic/protobufs.git [submodule "design"] path = design diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 226846f79..e01406911 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,7 +17,6 @@ import com.geeksville.mesh.buildlogic.Configs import com.geeksville.mesh.buildlogic.GitVersionValueSource -import com.google.protobuf.gradle.proto import java.io.FileInputStream import java.util.Properties @@ -32,7 +31,6 @@ plugins { alias(libs.plugins.meshtastic.android.room) alias(libs.plugins.kotlin.parcelize) alias(libs.plugins.meshtastic.kotlinx.serialization) - alias(libs.plugins.protobuf) alias(libs.plugins.devtools.ksp) alias(libs.plugins.datadog) alias(libs.plugins.secrets) @@ -147,7 +145,6 @@ android { bundle { language { enableSplit = false } } buildFeatures { aidl = true } sourceSets { - named("main") { proto { srcDir("src/main/proto") } } // Adds exported schema location as test app assets. named("androidTest") { assets.srcDirs(files("$projectDir/schemas")) } } @@ -164,27 +161,8 @@ datadog { // } } -// per protobuf-gradle-plugin docs, this is recommended for android -protobuf { - protoc { artifact = libs.protoc.get().toString() } - generateProtoTasks { - all().forEach { task -> - task.builtins { - create("java") {} - create("kotlin") {} - } - } - } -} - // workaround for https://github.com/google/ksp/issues/1590 androidComponents { - onVariants(selector().all()) { variant -> - project.afterEvaluate { - val variantNameCapped = variant.name.replaceFirstChar { it.uppercase() } - tasks.named("ksp${variantNameCapped}Kotlin") { dependsOn("generate${variantNameCapped}Proto") } - } - } onVariants(selector().withBuildType("release")) { variant -> if (variant.flavorName == "google") { val variantNameCapped = variant.name.replaceFirstChar { it.uppercase() } @@ -204,12 +182,12 @@ dependencies { implementation(projects.core.navigation) implementation(projects.core.network) implementation(projects.core.prefs) + implementation(projects.core.proto) // Bundles implementation(libs.bundles.markdown) implementation(libs.bundles.coroutines) implementation(libs.bundles.datastore) - implementation(libs.bundles.protobuf) implementation(libs.bundles.coil) // ZXing diff --git a/app/src/main/proto b/app/src/main/proto deleted file mode 160000 index 6a8b80a10..000000000 --- a/app/src/main/proto +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a8b80a10835acf48b2dfa2ad8aa0cc596219619 diff --git a/core/proto/build.gradle.kts b/core/proto/build.gradle.kts new file mode 100644 index 000000000..e914679f3 --- /dev/null +++ b/core/proto/build.gradle.kts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Meshtastic LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* + * Copyright (c) 2025 Meshtastic LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +plugins { + alias(libs.plugins.meshtastic.android.library) + alias(libs.plugins.protobuf) +} + +android { namespace = "org.meshtastic.core.proto" } + +// per protobuf-gradle-plugin docs, this is recommended for android +protobuf { + protoc { artifact = libs.protoc.get().toString() } + generateProtoTasks { + all().forEach { task -> + task.builtins { + create("java") {} + create("kotlin") {} + } + } + } +} + +dependencies { + // This needs to be API for consuming modules + api(libs.protobuf.kotlin) +} diff --git a/core/proto/src/main/proto b/core/proto/src/main/proto new file mode 160000 index 000000000..46b81e822 --- /dev/null +++ b/core/proto/src/main/proto @@ -0,0 +1 @@ +Subproject commit 46b81e822af1b8e408f437092337f129dee693e6 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ffc78c1cc..199f724e7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -199,7 +199,6 @@ coil = ["coil", "coil-network-core", "coil-network-okhttp", "coil-svg"] datadog = ["dd-sdk-android-compose", "dd-sdk-android-logs", "dd-sdk-android-okhttp", "dd-sdk-android-rum", "dd-sdk-android-session-replay", "dd-sdk-android-session-replay-compose", "dd-sdk-android-timber", "dd-sdk-android-trace", "dd-sdk-android-trace-otel"] markdown = ["markdown-renderer", "markdown-renderer-m3", "markdown-renderer-android"] osm = ["osmdroid-android", "osmbonuspack", "mgrs"] -protobuf = ["protobuf-kotlin"] # Testing testing = ["junit", "ext-junit"] diff --git a/mesh_service_example/build.gradle.kts b/mesh_service_example/build.gradle.kts index 3fa4ba691..1642db333 100644 --- a/mesh_service_example/build.gradle.kts +++ b/mesh_service_example/build.gradle.kts @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2025 Meshtastic LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +import com.geeksville.mesh.buildlogic.FlavorDimension +import com.geeksville.mesh.buildlogic.MeshtasticFlavor + /* * Copyright (c) 2025 Meshtastic LLC * @@ -20,36 +39,26 @@ plugins { alias(libs.plugins.meshtastic.android.application.compose) alias(libs.plugins.kotlin.parcelize) alias(libs.plugins.kotlin.serialization) - alias(libs.plugins.protobuf) alias(libs.plugins.kover) } android { namespace = "com.meshtastic.android.meshserviceexample" buildFeatures { aidl = true } -} - -// per protobuf-gradle-plugin docs, this is recommended for android -protobuf { - protoc { protoc { artifact = "com.google.protobuf:protoc:4.32.1" } } - generateProtoTasks { - all().forEach { task -> - task.builtins { - create("java") - create("kotlin") - } - } + defaultConfig { + // Force this app to use the Google variant of any modules it's using that apply AndroidLibraryConventionPlugin + missingDimensionStrategy(FlavorDimension.marketplace.name, MeshtasticFlavor.google.name) } } dependencies { + implementation(projects.core.proto) + implementation(libs.appcompat) implementation(libs.material) implementation(libs.activity) implementation(libs.constraintlayout) - implementation(libs.bundles.protobuf) - implementation(libs.kotlinx.serialization.json) // OSM diff --git a/mesh_service_example/src/main/proto b/mesh_service_example/src/main/proto deleted file mode 160000 index 6a8b80a10..000000000 --- a/mesh_service_example/src/main/proto +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a8b80a10835acf48b2dfa2ad8aa0cc596219619 diff --git a/settings.gradle.kts b/settings.gradle.kts index 45023e1e6..492eae87b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,7 +17,7 @@ import org.gradle.kotlin.dsl.maven * along with this program. If not, see . */ -include(":app", ":core:model", ":core:navigation", ":core:network", ":core:prefs", ":mesh_service_example") +include(":app", ":core:model", ":core:navigation", ":core:network", ":core:prefs", ":core:proto", ":mesh_service_example") rootProject.name = "MeshtasticAndroid" // https://docs.gradle.org/current/userguide/declaring_dependencies.html#sec:type-safe-project-accessors