From a3e9539d97764400e021de0b66be49674bb0e874 Mon Sep 17 00:00:00 2001 From: Karan Sharma <55722391+ksharma-xyz@users.noreply.github.com> Date: Sat, 22 Feb 2025 20:31:46 +1100 Subject: [PATCH] Create :io:gtfs module --- IO/gtfs/README.md | 4 ++ IO/gtfs/build.gradle.kts | 70 ++++++++++++++++++++++ IO/gtfs/src/commonMain/proto/NswStop.proto | 22 +++++++ build.gradle.kts | 1 + gradle/libs.versions.toml | 3 + settings.gradle.kts | 1 + 6 files changed, 101 insertions(+) create mode 100644 IO/gtfs/README.md create mode 100644 IO/gtfs/build.gradle.kts create mode 100644 IO/gtfs/src/commonMain/proto/NswStop.proto diff --git a/IO/gtfs/README.md b/IO/gtfs/README.md new file mode 100644 index 00000000..cd4cdb59 --- /dev/null +++ b/IO/gtfs/README.md @@ -0,0 +1,4 @@ +### Wire - Protobuf + +Run `./gradlew generateCommonMainProtos`, to generate Kotlin files form .proto files. +The files will be generated in the following dir: `build/generated/source/wire/` diff --git a/IO/gtfs/build.gradle.kts b/IO/gtfs/build.gradle.kts new file mode 100644 index 00000000..e5d3e2e5 --- /dev/null +++ b/IO/gtfs/build.gradle.kts @@ -0,0 +1,70 @@ +android { + namespace = "xyz.ksharma.krail.io.gtfs" +} + +plugins { + alias(libs.plugins.krail.android.library) + alias(libs.plugins.krail.kotlin.multiplatform) + alias(libs.plugins.krail.compose.multiplatform) + alias(libs.plugins.compose.compiler) + alias(libs.plugins.wire) +} + +kotlin { + applyDefaultHierarchyTemplate() + + androidTarget() + iosArm64() + iosSimulatorArm64() + + sourceSets { + androidMain.dependencies { + api(libs.di.koinAndroid) + } + + commonMain { + dependencies { + implementation(projects.core.log) + implementation(projects.core.di) + + implementation(libs.kotlinx.serialization.json) + implementation(libs.ktor.client.core) + implementation(libs.ktor.client.auth) + implementation(libs.ktor.client.content.negotiation) + implementation(libs.ktor.client.logging) + implementation(libs.ktor.serialization.kotlinx.json) + implementation(libs.kotlinx.datetime) + implementation(compose.runtime) + + api(libs.di.koinComposeViewmodel) + } + } + + iosMain { + dependencies { + } + } + + commonTest { + dependencies { + implementation(libs.test.kotlin) + implementation(libs.test.turbine) + implementation(libs.test.kotlinxCoroutineTest) + } + } + } +} + + +wire { + kotlin { + javaInterop = true + out = "$projectDir/build/generated/source/wire" + } + protoPath { + srcDir("src/commonMain/proto") + } + sourcePath { + srcDir("src/commonMain/proto") + } +} diff --git a/IO/gtfs/src/commonMain/proto/NswStop.proto b/IO/gtfs/src/commonMain/proto/NswStop.proto new file mode 100644 index 00000000..b3da7d74 --- /dev/null +++ b/IO/gtfs/src/commonMain/proto/NswStop.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package app.krail.kgtfs.proto; + +message NswStop { + + /** The stop ID is a unique identifier for the stop. */ + string stopId = 1; + + // The stop name is the name of the stop. + string stopName = 2; + + double lat = 3; + double lon = 4; + + // The product class is a list of transport modes that the stop is associated with. + repeated int32 productClass = 5; +} + +message NswStopList { + repeated NswStop nswStops = 1; +} diff --git a/build.gradle.kts b/build.gradle.kts index c8e02543..ee4e3d87 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,4 +12,5 @@ plugins { alias(libs.plugins.kotlinMultiplatform) apply false alias(libs.plugins.firebase.crashlyticsPlugin) apply false alias(libs.plugins.firebase.performancePlugin) apply false + alias(libs.plugins.wire) apply false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9fc405a4..8b1aa924 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,6 +11,7 @@ android-lifecycle = "2.8.7" activity-compose = "1.9.3" kotlinxCollectionsImmutable = "0.3.8" kotlinxDatetime = "0.6.2" +kotlinxIoCore = "0.6.0" lifecycleViewmodelCompose = "2.8.4" navigationCompose = "2.8.0-alpha10" kotlinxSerializationJson = "1.8.0" @@ -32,6 +33,7 @@ activity-compose = { group = "androidx.activity", name = "activity-compose", ver kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinxCollectionsImmutable" } kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" } +kotlinx-io-core = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinxIoCore" } lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "android-lifecycle" } navigation-compose = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "navigationCompose" } kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" } @@ -97,6 +99,7 @@ kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = sqldelight = { id = "app.cash.sqldelight", version.ref = "sqlDelight" } firebase-crashlyticsPlugin = { id = "com.google.firebase.crashlytics", version = "3.0.3" } firebase-performancePlugin = { id ="com.google.firebase.firebase-perf", version = "1.4.2" } +wire = { id = "com.squareup.wire", version = "5.3.0" } #Convention Plugins krail-android-application = { id = "krail.android.application", version = "unspecified" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 1a703934..600a0b68 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -46,3 +46,4 @@ include(":feature:trip-planner:state") include(":feature:trip-planner:network") include(":sandook") include(":gtfs-static") +include(":io:gtfs")