Skip to content

Commit 467dfec

Browse files
committed
Mini 4.0.0
Fix mini-processor-test Add rules for StateContainer
1 parent 82b8f76 commit 467dfec

File tree

29 files changed

+224
-91
lines changed

29 files changed

+224
-91
lines changed

.idea/kotlinc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
### Security
1919
- No security issues fixed!
2020

21+
## [4.0.0] - 2023-10-31
22+
## 🎃🎃 Happy Halloween! 🎃🎃
23+
### Changed
24+
- BREAKING CHANGE: Mini has been updated to use Java 17 instead of Java 8.
25+
- BREAKING CHANGE: Mini states must now implement `mini.State`.
26+
- Update all project dependencies.
27+
- Update documentation.
28+
2129
## [3.1.0] - 2022-09-18
2230
### Added
2331
- Add **EXPERIMENTAL** support for Kotlin Symbol Processing (KSP). Be mindful of [the gotchas](README.md#ksp-gotchas).
@@ -174,7 +182,8 @@ state (`success` or `failure`)
174182
### Added
175183
- Initial architecture release.
176184

177-
[Unreleased]: https://github.com/hyperdevs-team/mini-kotlin/compare/3.1.0...HEAD
185+
[Unreleased]: https://github.com/hyperdevs-team/mini-kotlin/compare/4.0.0...HEAD
186+
[4.0.0]: https://github.com/hyperdevs-team/mini-kotlin/compare/3.1.0...4.0.0
178187
[3.1.0]: https://github.com/hyperdevs-team/mini-kotlin/compare/3.0.0...3.1.0
179188
[3.0.0]: https://github.com/hyperdevs-team/mini-kotlin/compare/2.0.0...3.0.0
180189
[2.0.0]: https://github.com/hyperdevs-team/mini-kotlin/compare/1.4.0...2.0.0

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ ksp("com.github.hyperdevs-team.mini-kotlin:mini-processor:${miniVersion}")
147147

148148
</details>
149149

150-
### JDK8 requirements
151-
Ensure that your project has compatibility with Java 8:
150+
### JDK
151+
Ensure that your project has compatibility with Java 17:
152152

153153
For Kotlin projects:
154154
```groovy
155155
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
156156
kotlinOptions {
157-
jvmTarget = "1.8"
157+
jvmTarget = "17"
158158
}
159159
}
160160
```
@@ -163,12 +163,12 @@ For Android:
163163
```groovy
164164
android {
165165
compileOptions {
166-
sourceCompatibility = JavaVersion.VERSION_1_8
167-
targetCompatibility = JavaVersion.VERSION_1_8
166+
sourceCompatibility = JavaVersion.VERSION_17
167+
targetCompatibility = JavaVersion.VERSION_17
168168
}
169169
170170
kotlinOptions {
171-
jvmTarget = "1.8"
171+
jvmTarget = "17"
172172
}
173173
}
174174
```

app/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ apply plugin: "kotlin-kapt"
2828
apply plugin: "com.google.devtools.ksp"
2929

3030
android {
31-
compileSdkVersion android_target_sdk
32-
buildToolsVersion android_build_tools_version
31+
compileSdk = android_target_sdk
32+
buildToolsVersion = android_build_tools_version
3333

3434
namespace "com.example.androidsample"
3535

@@ -55,19 +55,19 @@ android {
5555
}
5656

5757
compileOptions {
58-
sourceCompatibility JavaVersion.VERSION_1_8
59-
targetCompatibility JavaVersion.VERSION_1_8
58+
sourceCompatibility JavaVersion.VERSION_17
59+
targetCompatibility JavaVersion.VERSION_17
6060
}
6161

6262
kotlinOptions {
63-
jvmTarget = "1.8"
63+
jvmTarget = "17"
6464
}
6565
lint {
6666
abortOnError false
6767
}
6868

69-
configurations.all {
70-
//This is library is included with two different versions
69+
configurations.configureEach {
70+
//This library is included with two different versions
7171
resolutionStrategy.force "com.google.code.findbugs:jsr305:3.0.1"
7272
}
7373
}

app/src/main/java/com/example/androidsample/SampleActions.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import mini.Reducer
2121
import mini.SuspendingAction
2222
import java.io.Serializable
2323

24-
data class State(
24+
data class MainState(
2525
val text: String = "0",
2626
val loading: Boolean = false
27-
) : Serializable
27+
) : Serializable, mini.State
2828

2929
@Action
3030
data class SetLoadingAction(val loading: Boolean)

app/src/main/java/com/example/androidsample/StoreSampleActivity.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ import mini.android.FluxActivity
3030

3131
private val dispatcher = Dispatcher()
3232

33-
class MainStore : Store<State>() {
33+
class MainStore : Store<MainState>() {
3434

3535
init {
3636
Mini.link(dispatcher, this).track()
3737
}
3838

3939
@Reducer
40-
fun handleLoading(state: State, action: SetLoadingAction): State {
40+
fun handleLoading(state: MainState, action: SetLoadingAction): MainState {
4141
return state.copy(loading = action.loading)
4242
}
4343

4444
@Reducer
45-
fun handleSetTextAction(state: State, action: SetTextAction): State {
45+
fun handleSetTextAction(state: MainState, action: SetTextAction): MainState {
4646
return state.copy(text = action.text)
4747
}
4848

app/src/main/java/com/example/androidsample/ViewModelSampleActivity.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,33 @@ import mini.android.FluxStoreViewModel
3232

3333
private val dispatcher = Dispatcher()
3434

35-
class MainViewModelReducer : NestedStateContainer<State>() {
35+
class MainViewModelReducer : NestedStateContainer<MainState>() {
3636

3737
@Reducer
38-
fun handleLoading(state: State, action: SetLoadingAction): State {
38+
fun handleLoading(state: MainState, action: SetLoadingAction): MainState {
3939
return state.copy(loading = action.loading)
4040
}
4141

4242
@Reducer
43-
fun handleSetTextAction(state: State, action: SetTextAction): State {
43+
fun handleSetTextAction(state: MainState, action: SetTextAction): MainState {
4444
return state.copy(text = action.text)
4545
}
4646
}
4747

48-
class MainStoreViewModel(savedStateHandle: SavedStateHandle) : FluxStoreViewModel<State>(savedStateHandle) {
48+
class MainStoreViewModel(savedStateHandle: SavedStateHandle) : FluxStoreViewModel<MainState>(savedStateHandle) {
4949
private val reducerSlice = MainViewModelReducer().apply { parent = this@MainStoreViewModel }
5050

5151
init {
5252
Mini.link(dispatcher, listOf(this, reducerSlice)).track()
5353
}
5454

55-
override fun saveState(state: State, handle: SavedStateHandle) {
55+
override fun saveState(state: MainState, handle: SavedStateHandle) {
5656
println("State saved")
5757
handle.set("state", state)
5858
}
5959

60-
override fun restoreState(handle: SavedStateHandle): State? {
61-
val restored = handle.get<State>("state")
60+
override fun restoreState(handle: SavedStateHandle): MainState? {
61+
val restored = handle.get<MainState>("state")
6262
println("State restored $restored")
6363
return restored
6464
}

build.gradle

+14-14
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ apply plugin: "com.gladed.androidgitversion"
2121

2222
buildscript {
2323
ext {
24-
kotlin_version = "1.7.0"
24+
kotlin_version = "1.9.10"
2525

26-
android_compile_sdk = 33
27-
android_target_sdk = 33
28-
android_build_tools_version = "30.0.3"
26+
android_compile_sdk = 34
27+
android_target_sdk = 34
28+
android_build_tools_version = "34.0.0"
2929

30-
activity_version = "1.5.0"
31-
fragment_version = "1.5.0"
32-
lifecycle_version = "2.5.1"
33-
coroutines_version = "1.6.4"
30+
activity_version = "1.8.0"
31+
fragment_version = "1.6.1"
32+
lifecycle_version = "2.6.2"
33+
coroutines_version = "1.7.3"
3434

35-
kodein_version = "7.14.0"
35+
kodein_version = "7.20.2"
3636

3737
junit_version = "4.13.2"
38-
test_runner_version = "1.4.0"
39-
espresso_version = "3.4.0"
38+
test_runner_version = "1.5.2"
39+
espresso_version = "3.5.1"
4040
kluent_version = "1.68"
4141

42-
ksp_version = "${kotlin_version}-1.0.6"
42+
ksp_version = "${kotlin_version}-1.0.13"
4343
}
4444

4545
repositories {
@@ -49,11 +49,11 @@ buildscript {
4949
}
5050

5151
dependencies {
52-
classpath "com.android.tools.build:gradle:7.2.2"
52+
classpath "com.android.tools.build:gradle:8.1.2"
5353
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
5454
classpath "org.junit.platform:junit-platform-gradle-plugin:1.2.0"
5555
classpath "com.gladed.androidgitversion:gradle-android-git-version:0.4.14"
56-
classpath "com.github.ben-manes:gradle-versions-plugin:0.42.0"
56+
classpath "com.github.ben-manes:gradle-versions-plugin:0.48.0"
5757
classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$ksp_version"
5858
}
5959
}
+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Fri Jul 08 11:00:27 CEST 2022
21
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
42
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
64
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

jitpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
jdk:
2-
- openjdk11
2+
- openjdk17

mini-android/build.gradle

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
13
/*
24
* Copyright 2021 HyperDevs
35
*
@@ -20,8 +22,8 @@ apply plugin: "com.android.library"
2022
apply plugin: "kotlin-android"
2123

2224
android {
23-
compileSdkVersion android_compile_sdk
24-
buildToolsVersion android_build_tools_version
25+
compileSdk = android_compile_sdk
26+
buildToolsVersion = android_build_tools_version
2527

2628
namespace "mini.android"
2729

@@ -39,8 +41,16 @@ android {
3941
}
4042
}
4143

44+
compileOptions {
45+
sourceCompatibility JavaVersion.VERSION_17
46+
targetCompatibility JavaVersion.VERSION_17
47+
}
48+
}
49+
50+
tasks.withType(KotlinCompile).configureEach {
4251
kotlinOptions {
43-
jvmTarget = "1.8"
52+
jvmTarget = "17"
53+
4454
freeCompilerArgs += [
4555
"-opt-in=kotlin.Experimental",
4656
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
@@ -52,7 +62,7 @@ dependencies {
5262
api project(':mini-common')
5363

5464
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
55-
api "androidx.appcompat:appcompat:1.4.2"
65+
api "androidx.appcompat:appcompat:1.6.1"
5666
api "androidx.activity:activity-ktx:$activity_version"
5767
api "androidx.fragment:fragment-ktx:$fragment_version"
5868

mini-android/src/main/java/mini/android/FluxStoreViewModel.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import androidx.lifecycle.SavedStateHandle
2020
import androidx.lifecycle.ViewModel
2121
import mini.CloseableTracker
2222
import mini.DefaultCloseableTracker
23+
import mini.State
2324
import mini.StateContainer
2425
import mini.assertOnUiThread
2526
import java.io.Closeable
2627
import java.util.concurrent.CopyOnWriteArrayList
2728

28-
abstract class FluxStoreViewModel<S : Any>(
29+
abstract class FluxStoreViewModel<S : State>(
2930
val savedStateHandle: SavedStateHandle) :
3031
ViewModel(),
3132
StateContainer<S>,

mini-common/build.gradle

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
13
/*
24
* Copyright 2021 HyperDevs
35
*
@@ -16,12 +18,11 @@
1618
* limitations under the License.
1719
*/
1820

19-
apply plugin: 'kotlin'
2021
apply plugin: "kotlin"
2122
apply from: "../jitpack.gradle"
2223

2324
dependencies {
24-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
25+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
2526
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
2627

2728
// Optional Rx and Android bindings, one day these should be modules,
@@ -35,12 +36,20 @@ dependencies {
3536
testImplementation "org.amshove.kluent:kluent:$kluent_version"
3637
}
3738

38-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
39-
kotlinOptions.freeCompilerArgs += [
40-
"-opt-in=kotlin.Experimental",
41-
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
42-
"-opt-in=kotlinx.coroutines.FlowPreview",
43-
]
39+
tasks.withType(KotlinCompile).configureEach {
40+
kotlinOptions {
41+
jvmTarget = "17"
42+
43+
freeCompilerArgs += [
44+
"-opt-in=kotlin.Experimental",
45+
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
46+
"-opt-in=kotlinx.coroutines.FlowPreview"]
47+
}
48+
}
49+
50+
java {
51+
sourceCompatibility = JavaVersion.VERSION_17
52+
targetCompatibility = JavaVersion.VERSION_17
4453
}
4554

4655
apply plugin: "idea"

mini-common/src/main/java/mini/Mini.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ abstract class Mini {
7070
/**
7171
* Link all [Reducer] functions present in the store to the dispatcher.
7272
*/
73-
protected abstract fun <S> subscribe(dispatcher: Dispatcher, container: StateContainer<S>): Closeable
73+
protected abstract fun <S: State> subscribe(dispatcher: Dispatcher,
74+
container: StateContainer<S>): Closeable
7475

7576
/**
7677
* Link all [Reducer] functions present in the store to the dispatcher.

mini-common/src/main/java/mini/NestedStateContainer.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ import java.io.Closeable
4242
* }
4343
* ```
4444
*/
45-
abstract class NestedStateContainer<S : Any>(var parent: StateContainer<S>? = null) : StateContainer<S> {
45+
abstract class NestedStateContainer<S : State>(
46+
var parent: StateContainer<S>? = null
47+
) : StateContainer<S> {
4648
override val state: S
4749
get() = parent!!.state
4850

0 commit comments

Comments
 (0)