-
Notifications
You must be signed in to change notification settings - Fork 3
[issue-17] - common main to android main #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
48d9600
9233012
89717f7
881624d
331540d
5905ff1
9eda793
aeddeae
48b3de5
78783ab
45264b7
3831391
c45120d
bf70520
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package extensions | ||
|
|
||
| import Config | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
|
||
| fun KotlinMultiplatformExtension.iosTarget() { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Define iosTarget, but not implementing it yet |
||
| listOf( | ||
| iosX64(), | ||
| iosArm64(), | ||
| iosSimulatorArm64() | ||
| ).forEach { iosTarget -> | ||
| iosTarget.binaries.framework { | ||
| baseName = Config.appName | ||
| isStatic = true | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,10 @@ plugins { | |
| } | ||
| kotlin { | ||
| sourceSets { | ||
| androidMain.dependencies { | ||
| implementation(libs.koin.android) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Koin android is android specific |
||
| implementation(libs.lottie) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lottie is also android specific |
||
| } | ||
| commonMain.dependencies { | ||
| implementation(projects.featureListStreams) | ||
| implementation(projects.featureDetail) | ||
|
|
@@ -19,13 +23,13 @@ kotlin { | |
| implementation(projects.coreLocalStorage) | ||
|
|
||
| implementation(libs.navigation.compose) | ||
|
|
||
| implementation(compose.material3) | ||
| implementation(compose.ui) | ||
| implementation(compose.preview) | ||
| implementation(libs.bundles.koin) | ||
| implementation(libs.bundles.androidSupport) | ||
| implementation(libs.bundles.kotlin) | ||
| implementation(libs.lottie) | ||
|
|
||
| implementation(libs.koin.core) | ||
| implementation(libs.koin.compose) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,19 +9,8 @@ kotlin { | |
| commonMain.dependencies { | ||
| implementation(libs.room.bundled) | ||
| implementation(libs.room.runtime) | ||
| implementation(libs.bundles.kotlin) | ||
| implementation(libs.bundles.koin) | ||
| } | ||
| } | ||
|
|
||
| listOf( | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's move this definition to the base conventional plugin |
||
| iosX64(), | ||
| iosArm64(), | ||
| iosSimulatorArm64() | ||
| ).forEach { iosTarget -> | ||
| iosTarget.binaries.framework { | ||
| baseName = "composeApp" | ||
| isStatic = true | ||
| implementation(libs.koin.core) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -33,10 +22,6 @@ dependencies { | |
| add("kspIosArm64", libs.room.compiler) | ||
| } | ||
|
|
||
| configurations.implementation{ | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need it anymore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This we need (bringing back): what we don't need is: |
||
| exclude(group = "com.intellij", module = "annotations") | ||
| } | ||
|
|
||
| room { | ||
| schemaDirectory("$projectDir/schemas") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,50 @@ | ||
| import com.codingfeline.buildkonfig.compiler.FieldSpec | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep buildtype release, cause is good example how to use |
||
|
|
||
| plugins { | ||
| id("com.streamplayer.kmp-library") | ||
| alias(libs.plugins.jetbrains.compose) | ||
| alias(libs.plugins.compose.compiler) | ||
| alias(libs.plugins.buildkonfig.plugin) | ||
| } | ||
|
|
||
| android { | ||
| buildFeatures { | ||
| buildConfig = true | ||
| buildkonfig { | ||
| packageName = "core.networking" | ||
|
|
||
| defaultConfigs { | ||
| buildConfigField(FieldSpec.Type.STRING, "HOST", Config.BuildField.host_debug) | ||
| buildConfigField(FieldSpec.Type.STRING, "API_BEARER_AUTH", Config.BuildField.api_bearer_debug) | ||
| buildConfigField(FieldSpec.Type.STRING, "PROFILE", Config.BuildField.api_profile_debug) | ||
| } | ||
| buildTypes { | ||
| debug { | ||
| buildConfigField("String", "HOST", Config.BuildField.host_debug) | ||
| buildConfigField("String", "API_BEARER_AUTH", Config.BuildField.api_bearer_debug) | ||
| buildConfigField("String", "PROFILE", Config.BuildField.api_profile_debug) | ||
|
|
||
| } | ||
| getByName("release") { | ||
| buildConfigField("String", "HOST", Config.BuildField.host_release) | ||
| buildConfigField("String", "API_BEARER_AUTH", Config.BuildField.api_bearer_release) | ||
| buildConfigField("String", "PROFILE", Config.BuildField.api_profile_release) | ||
| } | ||
| defaultConfigs("release") { | ||
| buildConfigField(FieldSpec.Type.STRING, "HOST", Config.BuildField.host_release) | ||
| buildConfigField(FieldSpec.Type.STRING, "API_BEARER_AUTH", Config.BuildField.api_bearer_release) | ||
| buildConfigField(FieldSpec.Type.STRING, "PROFILE", Config.BuildField.api_profile_release) | ||
| } | ||
| } | ||
|
|
||
| kotlin { | ||
| sourceSets { | ||
| commonMain.dependencies { | ||
| implementation(libs.bundles.kotlin) | ||
| implementation(libs.bundles.networking) | ||
| implementation(libs.bundles.koin) | ||
| implementation(libs.kotlin.stdlib) | ||
|
|
||
| implementation(libs.koin.core) | ||
| implementation(libs.ktor.client.core) | ||
| implementation(libs.ktor.client.content.serialization.json) | ||
| implementation(libs.ktor.client.content.negotiation) | ||
| implementation(libs.ktor.client.logger) | ||
| implementation(libs.ktor.client.auth) | ||
|
|
||
| implementation(compose.components.resources) | ||
| implementation(compose.runtime) | ||
| } | ||
|
|
||
| androidMain.dependencies { | ||
| implementation(libs.okhttp) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Android specific network dependencies |
||
|
|
||
| implementation(libs.interceptor) | ||
|
|
||
| implementation(libs.ktor.client.okhttp) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.codandotv.streamplayerapp.core_networking | ||
|
|
||
| import io.ktor.client.engine.HttpClientEngine | ||
| import io.ktor.client.engine.okhttp.OkHttpConfig | ||
| import io.ktor.client.engine.okhttp.OkHttpEngine | ||
|
|
||
| actual fun httpClientEnginePlatform() : HttpClientEngine = OkHttpEngine(OkHttpConfig()) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| @file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE") | ||
|
|
||
| package com.codandotv.streamplayerapp.core_networking | ||
|
|
||
| import io.ktor.client.engine.HttpClientEngine | ||
|
|
||
| expect fun httpClientEnginePlatform(): HttpClientEngine |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,10 @@ | ||
| package com.codandotv.streamplayerapp.core_networking.di | ||
|
|
||
| import android.util.Log | ||
| import com.codandotv.streamplayerapp.core.networking.BuildConfig | ||
| import com.codandotv.streamplayerapp.core_networking.di.Network.TIMEOUT | ||
| import com.codandotv.streamplayerapp.core_networking.handleError.validator | ||
| import com.squareup.moshi.Moshi | ||
| import com.codandotv.streamplayerapp.core_networking.httpClientEnginePlatform | ||
| import core.networking.BuildKonfig | ||
| import io.ktor.client.HttpClient | ||
| import io.ktor.client.HttpClientConfig | ||
| import io.ktor.client.engine.okhttp.OkHttp | ||
| import io.ktor.client.engine.okhttp.OkHttpConfig | ||
| import io.ktor.client.plugins.HttpResponseValidator | ||
| import io.ktor.client.plugins.HttpTimeout | ||
| import io.ktor.client.plugins.auth.Auth | ||
| import io.ktor.client.plugins.auth.providers.BearerTokens | ||
|
|
@@ -23,81 +18,63 @@ import io.ktor.client.request.accept | |
| import io.ktor.http.ContentType | ||
| import io.ktor.http.contentType | ||
| import io.ktor.serialization.kotlinx.json.json | ||
| import kotlinx.serialization.ExperimentalSerializationApi | ||
| import kotlinx.serialization.json.Json | ||
| import okhttp3.Interceptor | ||
| import org.koin.dsl.module | ||
|
|
||
| object NetworkModule { | ||
| val module = module { | ||
| single(QualifierHost) { BuildConfig.HOST } | ||
| single(QualifierProfile) { BuildConfig.PROFILE } | ||
| single(QualifierHost) { BuildKonfig.HOST } | ||
| single(QualifierProfile) { BuildKonfig.PROFILE } | ||
|
|
||
| single { | ||
| provideKtorHttpClient( | ||
| moshi = get(), | ||
| baseUrl = get(QualifierHost), | ||
| ) | ||
| } | ||
|
|
||
| single(QualifierProfileHttpClient) { | ||
| provideKtorHttpClient( | ||
| moshi = get(), | ||
| baseUrl = get(QualifierProfile), | ||
| ) | ||
| } | ||
|
|
||
| single { Moshi.Builder().build() } | ||
| } | ||
|
|
||
| private fun provideKtorHttpClient( | ||
| moshi: Moshi, | ||
| baseUrl: String, | ||
| ): HttpClient { | ||
| return HttpClient(OkHttp) { | ||
| installPlugins(moshi, baseUrl) | ||
| } | ||
| } | ||
|
|
||
| private fun HttpClientConfig<OkHttpConfig>.installPlugins( | ||
| moshi: Moshi, | ||
| baseUrl: String, | ||
| ) { | ||
| expectSuccess = false | ||
|
|
||
| install(ContentNegotiation) { | ||
| json(Json { | ||
| explicitNulls = false | ||
| ignoreUnknownKeys = true | ||
| }) | ||
| } | ||
| return HttpClient(engine = httpClientEnginePlatform()) { | ||
| expectSuccess = false | ||
|
|
||
| install(HttpTimeout) { | ||
| socketTimeoutMillis = TIMEOUT | ||
| requestTimeoutMillis = TIMEOUT | ||
| connectTimeoutMillis = TIMEOUT | ||
| } | ||
| install(ContentNegotiation) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. não entendi, pq precisou mudar essas coisas |
||
| json(Json { | ||
| explicitNulls = false | ||
| ignoreUnknownKeys = true | ||
| }) | ||
| } | ||
|
|
||
| defaultRequest { | ||
| url(baseUrl) | ||
| contentType(ContentType.Application.Json) | ||
| accept(ContentType.Application.Json) | ||
| } | ||
| install(HttpTimeout) { | ||
| socketTimeoutMillis = TIMEOUT | ||
| requestTimeoutMillis = TIMEOUT | ||
| connectTimeoutMillis = TIMEOUT | ||
| } | ||
|
|
||
| validator(moshi) | ||
| defaultRequest { | ||
| url(baseUrl) | ||
| contentType(ContentType.Application.Json) | ||
| accept(ContentType.Application.Json) | ||
| } | ||
|
|
||
| install(Auth) { | ||
| bearer { | ||
| loadTokens { | ||
| BearerTokens( | ||
| accessToken = BuildConfig.API_BEARER_AUTH, | ||
| refreshToken = "" | ||
| ) | ||
| install(Auth) { | ||
| bearer { | ||
| loadTokens { | ||
| BearerTokens( | ||
| accessToken = BuildKonfig.API_BEARER_AUTH, | ||
| refreshToken = "" | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (BuildConfig.DEBUG) { | ||
| install(Logging) { | ||
| level = LogLevel.ALL | ||
| logger = object : Logger { | ||
|
|
@@ -110,6 +87,6 @@ object NetworkModule { | |
| } | ||
| } | ||
|
|
||
| internal object Network{ | ||
| internal object Network { | ||
| const val TIMEOUT = 10000L | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aqui mesma coisa