Skip to content

Commit 65bd90b

Browse files
Merge pull request #190 from futuredapp/feature/6.x-stable-context-params
Bump Kotlin version to 2.4
2 parents dcf5f0d + ea4b203 commit 65bd90b

9 files changed

Lines changed: 7 additions & 62 deletions

File tree

buildSrc/src/main/kotlin/Deps.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ object Deps {
2424
const val hiltPlugin = "com.google.dagger:hilt-android-gradle-plugin:${Versions.hilt}"
2525
const val hilt = "com.google.dagger:hilt-android:${Versions.hilt}"
2626
const val hiltCompiler = "com.google.dagger:hilt-android-compiler:${Versions.hilt}"
27+
const val kotlinMetadata = "org.jetbrains.kotlin:kotlin-metadata-jvm:${Versions.kotlin}"
2728

2829
const val hiltViewModelCompose = "androidx.hilt:hilt-lifecycle-viewmodel-compose:${Versions.hiltJetpack}"
2930
}

buildSrc/src/main/kotlin/Versions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Versions {
1010
const val dokka = "1.6.10"
1111

1212
// kotlin
13-
const val kotlin = "2.3.10"
13+
const val kotlin = "2.4.0"
1414
const val ksp = "2.3.5"
1515
const val coroutines = "1.10.2"
1616

cr-usecases-test/build.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ android {
2929

3030
kotlin {
3131
jvmToolchain(17)
32-
compilerOptions {
33-
freeCompilerArgs.add("-Xcontext-parameters")
34-
}
3532
}
3633

3734
mavenPublishing {

cr-usecases/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ kotlin {
1717
minSdk = ProjectSettings.minSdk
1818
}
1919

20-
compilerOptions {
21-
freeCompilerArgs.add("-Xcontext-parameters")
22-
}
23-
2420
sourceSets {
2521
commonMain {
2622
dependencies {

cr-usecases/src/commonMain/kotlin/app/futured/arkitekt/crusecases/FlowUseCaseExecution.kt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,3 @@ private fun <ARGS, T : Any?> FlowUseCase<ARGS, T>.internalExecute(
7373
}.catch { /* handled in onCompletion */ }
7474
.launchIn(coroutineScopeOwner.useCaseScope)
7575
}
76-
77-
78-
@Deprecated(
79-
message = "Use the version with CoroutineScopeOwner as context parameter instead. Enable context parameters by adding '-Xcontext-receivers' compiler flag.",
80-
replaceWith = ReplaceWith("execute(args, config)", imports = ["app.futured.arkitekt.crusecases.execute"])
81-
)
82-
fun <ARGS, T : Any?> FlowUseCase<ARGS, T>.execute(
83-
args: ARGS,
84-
coroutineScopeOwner: CoroutineScopeOwner,
85-
config: FlowUseCaseConfig.Builder<T, T>.() -> Unit,
86-
) {
87-
internalExecute(args, coroutineScopeOwner, config)
88-
}
89-
90-
@Deprecated(
91-
message = "Use the version with CoroutineScopeOwner as context parameter instead. Enable context parameters by adding '-Xcontext-receivers' compiler flag.",
92-
replaceWith = ReplaceWith("execute(config)", imports = ["app.futured.arkitekt.crusecases.execute"])
93-
)
94-
fun <T : Any?> FlowUseCase<Unit, T>.execute(
95-
coroutineScopeOwner: CoroutineScopeOwner,
96-
config: FlowUseCaseConfig.Builder<T, T>.() -> Unit,
97-
) {
98-
internalExecute(Unit, coroutineScopeOwner, config)
99-
}

cr-usecases/src/commonMain/kotlin/app/futured/arkitekt/crusecases/UseCaseExecution.kt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,6 @@ suspend fun <ARGS, T : Any?> UseCase<ARGS, T>.execute(
8585
}
8686
}
8787

88-
@Deprecated(
89-
message = "Use the version with CoroutineScopeOwner as context parameter instead. Enable context parameters by adding '-Xcontext-receivers' compiler flag.",
90-
replaceWith = ReplaceWith("execute(args, config)", imports = ["app.futured.arkitekt.crusecases.execute"])
91-
)
92-
fun <ARGS, T : Any?> UseCase<ARGS, T>.execute(
93-
args: ARGS,
94-
coroutineScopeOwner: CoroutineScopeOwner,
95-
config: UseCaseConfig.Builder<T>.() -> Unit,
96-
) {
97-
internalExecute(args, coroutineScopeOwner, config)
98-
}
99-
100-
@Deprecated(
101-
message = "Use the version with CoroutineScopeOwner as context parameter instead. Enable context parameters by adding '-Xcontext-receivers' compiler flag.",
102-
replaceWith = ReplaceWith("execute(args, config)", imports = ["app.futured.arkitekt.crusecases.execute"])
103-
)
104-
fun <T : Any?> UseCase<Unit, T>.execute(
105-
coroutineScopeOwner: CoroutineScopeOwner,
106-
config: UseCaseConfig.Builder<T>.() -> Unit,
107-
) {
108-
internalExecute(Unit, coroutineScopeOwner, config)
109-
}
110-
11188
private fun <ARGS, T : Any?> UseCase<ARGS, T>.internalExecute(
11289
args: ARGS,
11390
coroutineScopeOwner: CoroutineScopeOwner,

example/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ android {
4545

4646
kotlin {
4747
jvmToolchain(17)
48-
compilerOptions {
49-
freeCompilerArgs.add("-Xcontext-parameters")
50-
}
5148
}
5249

5350
dependencies {
@@ -75,6 +72,10 @@ dependencies {
7572

7673
implementation(Deps.DI.hilt)
7774
ksp(Deps.DI.hiltCompiler)
75+
// Overrides the older kotlin-metadata-jvm bundled by hilt-compiler so the KSP/Hilt
76+
// processor can parse Kotlin 2.4.0 metadata (highest version on the processor classpath
77+
// wins). Mirrors android/nowinandroid's fix for google/dagger#5001.
78+
ksp(Deps.DI.kotlinMetadata)
7879

7980
// Unit tests
8081
testImplementation(Deps.Test.jUnit)

example/src/main/java/app/futured/arkitekt/sample/ui/form/FormViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class FormViewModel @AssistedInject constructor(
1919
) : BaseViewModel<FormViewState>() {
2020

2121
init {
22-
// example of usage without context parameter enabled
23-
observeFormUseCase.execute(this) {
22+
observeFormUseCase.execute {
2423
onNext { viewState.storedContent.value = "${it.first} ${it.second}" }
2524
onError { sendEvent(ShowToastEvent("Error :-(")) }
2625
}

example/src/main/java/app/futured/arkitekt/sample/ui/login/LoginViewModel.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ class LoginViewModel @Inject constructor(
2727
}
2828

2929
fun logIn() = with(viewState) {
30-
// example of usage without context parameter enabled
3130
loginCompletabler.execute(
3231
args = SyncLoginUseCase.LoginData(name.value, surname.value),
33-
coroutineScopeOwner = this@LoginViewModel
3432
) {
3533
onSuccess { sendEvent(ShowToastEvent("Successfully logged in!")) }
3634
onError { sendEvent(ShowToastEvent("Login error!")) }

0 commit comments

Comments
 (0)