Skip to content

Commit

Permalink
Add kotlin compile options for opt-in APIs (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
crocsandcoffee committed Dec 23, 2022
1 parent 339a31c commit 219bc14
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.decompose.ExperimentalDecomposeApi
import com.arkivanov.decompose.extensions.compose.jetbrains.lifecycle.LifecycleController
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
import kotlinx.coroutines.Dispatchers
Expand All @@ -28,7 +27,6 @@ import social.androiddev.common.theme.DodoTheme
import social.androiddev.root.composables.RootContent
import social.androiddev.root.navigation.DefaultRootComponent

@OptIn(ExperimentalDecomposeApi::class) // Using LifecycleController
fun main() {
startKoin {
modules(appModule())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android {
is com.android.build.api.dsl.ApplicationBaseFlavor -> {
targetSdk = 33
}

is com.android.build.api.dsl.LibraryBaseFlavor -> {
targetSdk = 33
}
Expand All @@ -29,10 +30,6 @@ android {
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}

fun Project.android(configure: com.android.build.api.dsl.CommonExtension<*, *, *, *>.() -> Unit) {
extensions.configure("android", configure)
}
32 changes: 23 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ subprojects {
}
}

/**
* Workaround for:
* The Kotlin source set androidAndroidTestRelease was configured but not added to any
* Kotlin compilation. You can add a source set to a target's compilation by connecting it
* with the compilation's default source set using 'dependsOn'.
* See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets
*
* Remove log pollution until Android support in KMP improves.
*/
afterEvaluate {
project.extensions.findByType<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension>()?.let { ext ->

/**
* Workaround for:
* The Kotlin source set androidAndroidTestRelease was configured but not added to any
* Kotlin compilation. You can add a source set to a target's compilation by connecting it
* with the compilation's default source set using 'dependsOn'.
* See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets
*
* Remove log pollution until Android support in KMP improves.
*/
ext.sourceSets.removeAll { sourceSet ->
setOf(
"androidAndroidTestRelease",
Expand All @@ -62,6 +63,19 @@ subprojects {
"androidTestFixturesRelease",
).contains(sourceSet.name)
}

/**
* _Multiplatform_ module-wide opt-in.
*/
ext.sourceSets {
all {
// For mapLatest
languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")

// For LifecycleController
languageSettings.optIn("com.arkivanov.decompose.ExperimentalDecomposeApi")
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import io.ktor.http.HttpStatusCode
import io.ktor.http.headersOf
import io.ktor.serialization.kotlinx.json.json
import io.ktor.utils.io.ByteReadChannel
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.Json
import social.androiddev.common.network.fixtures.homeFeed
Expand All @@ -32,7 +31,6 @@ import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue

@OptIn(ExperimentalCoroutinesApi::class)
class MastodonApiTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
*/
package social.androiddev.common.persistence.authentication

import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import social.androiddev.common.persistence.AuthenticationDatabase
import social.androiddev.common.persistence.provideTestSqlDriver
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull

@OptIn(ExperimentalCoroutinesApi::class)
internal class AuthenticationDatabaseTests {

@Test
Expand Down
9 changes: 0 additions & 9 deletions ui/desktop-webview/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ plugins {
id("org.openjfx.javafxplugin") version "0.0.13"
}

kotlin {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
}

dependencies {
implementation(compose.desktop.common)
}
Expand All @@ -25,7 +19,4 @@ javafx {
"javafx.web",
"javafx.media"
)

}


Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.arkivanov.decompose.ExperimentalDecomposeApi
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState
import social.androiddev.root.navigation.RootComponent
Expand All @@ -32,7 +31,6 @@ import social.androiddev.signedout.root.SignedOutRootContent
* App root composable that delegates business logic
* and decompose navigation to [RootComponent]
*/
@OptIn(ExperimentalDecomposeApi::class)
@Composable
fun RootContent(
component: RootComponent,
Expand All @@ -54,13 +52,11 @@ fun RootContent(
component = child.component,
)
}

is RootComponent.Child.SignedIn -> {
SignedInRoot(
component = child.component,
)
}

is RootComponent.Child.SignedOut -> {
SignedOutRoot(
component = child.component,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.arkivanov.decompose.ExperimentalDecomposeApi
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState
import kotlinx.coroutines.flow.StateFlow
Expand All @@ -32,7 +31,6 @@ import social.androiddev.timeline.TimelineContent
* currently signed in.
* Business logic and decompose navigation is delegated to [SignedInRootComponent].
*/
@OptIn(ExperimentalDecomposeApi::class)
@Composable
fun SignedInRootContent(
component: SignedInRootComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import com.arkivanov.decompose.ExperimentalDecomposeApi
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children
import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState
import social.androiddev.signedout.landing.LandingContent
Expand All @@ -29,7 +28,6 @@ import social.androiddev.signedout.signin.SignInContent
* currently signed out.
* Business logic and decompose navigation is delegated to [SignedOutRootComponent].
*/
@OptIn(ExperimentalDecomposeApi::class)
@Composable
fun SignedOutRootContent(
component: SignedOutRootComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ package social.androiddev.timeline.navigation

import com.arkivanov.essenty.instancekeeper.InstanceKeeper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.SharingStarted
Expand All @@ -38,8 +37,6 @@ class TimelineViewModel(

private val scope = CoroutineScope(mainContext + SupervisorJob())

// TODO@OMID - Add kotlin compiler args
@OptIn(ExperimentalCoroutinesApi::class)
val state: StateFlow<StoreResponse<List<FeedItemState>>> = homeTimelineRepository
.read(feedType, refresh = true)
.mapLatest(::render)
Expand Down

0 comments on commit 219bc14

Please sign in to comment.