Skip to content

Commit

Permalink
Bump versions and prepare for release 2.4.0 (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
elihart authored Oct 7, 2021
1 parent d2f01a2 commit 6b3c971
Show file tree
Hide file tree
Showing 56 changed files with 217 additions and 133 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## 2.4.0
- Add covariant recreation support (#565)
- Exposing unique subscription handling for custom flow operations (#560)
- Add support for restoring ViewModels that were initially created with a companion factory in a superclass #566

## 2.3.0
- Error handling enhancements (#540)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ buildscript {
}

plugins {
id("io.gitlab.arturbosch.detekt").version("1.16.0-RC2")
id("io.gitlab.arturbosch.detekt").version("1.18.1")
}

apply plugin: 'io.gitlab.arturbosch.detekt'
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ dependencies {
implementation(gradleApi())
implementation("com.android.tools.build:gradle:7.0.0")
implementation("org.jacoco:org.jacoco.core:0.8.5")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30")
}
14 changes: 7 additions & 7 deletions buildSrc/src/main/java/dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
object Versions {
// Build tools and SDK
const val buildTools = "30.0.3"
const val compileSdk = 30
const val gradlePlugin = "7.0.0"
const val kotlin = "1.5.21"
const val compileSdk = 31
const val gradlePlugin = "7.0.2"
const val kotlin = "1.5.30"
const val minSdk = 16
const val targetSdk = 29

Expand All @@ -15,23 +15,23 @@ object Versions {
const val cardview = "1.0.0"
const val constraintlayout = "2.0.0"
const val coordinatorLayout = "1.1.0"
const val compose = "1.0.2"
const val compose = "1.0.3"
const val core = "1.5.0"
const val fragment = "1.3.4"
const val lifecycle = "2.3.1"
const val navigation = "2.3.5"
const val navigationCompose = "2.4.0-alpha01"
const val navigationCompose = "2.4.0-alpha10"
const val recyclerview = "1.2.0"
const val room = "2.3.0"
const val viewModelCompose = "1.0.0-alpha05"
const val viewModelCompose = "2.4.0-rc01"

// Libraries
const val autoValue = "1.6.6"
const val dagger = "2.38.1"
const val epoxy = "4.0.0"
const val hilt = "2.36"
const val koin = "2.0.1"
const val kotlinCoroutines = "1.5.1"
const val kotlinCoroutines = "1.5.2"
const val lottie = "3.4.0"
const val moshi = "1.9.2"
const val multidex = "2.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class CounterViewModelTest {
@ClassRule
val mvrxTestRule = MvRxTestRule()
}
}
}
2 changes: 1 addition & 1 deletion detekt.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'io.gitlab.arturbosch.detekt'
tasks.detekt.jvmTarget = "1.8"

dependencies {
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.16.0-RC2"
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.18.1"
}

detekt {
Expand Down
7 changes: 5 additions & 2 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ formatting:
active: true

comments:
excludes: ['.*/test/.*', '.*Test.kt', '.*Spec.kt']
excludes: ['**/test/**', '.*Test.kt']
active: true
CommentOverPrivateFunction:
active: false
Expand Down Expand Up @@ -154,7 +154,7 @@ empty-blocks:
EmptyForBlock:
active: true
EmptyFunctionBlock:
active: true
active: false
ignoreOverridden: false
EmptyIfBlock:
active: true
Expand Down Expand Up @@ -261,6 +261,7 @@ naming:
excludeClassPattern: '$^'

performance:
excludes: ['**/test/**', '.*Test.kt']
active: true
ForEachOnRange:
active: false
Expand Down Expand Up @@ -303,6 +304,7 @@ potential-bugs:
active: true

style:
excludes: ['**/test/**', '.*Test.kt']
active: true
CollapsibleIfStatements:
active: true
Expand Down Expand Up @@ -339,6 +341,7 @@ style:
MandatoryBracesIfStatements:
active: false # TODO: consider this
MaxLineLength:
excludes: ['**/test/**', '.*Test.kt']
active: true
maxLineLength: 175
excludePackageStatements: false
Expand Down
2 changes: 1 addition & 1 deletion dogs/src/test/java/com/airbnb/mvrx/dogs/DogStateTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class DogStateTest {
val state = DogState(dogs = Success(listOf(dog)), lovedDogId = dog.id)
assertEquals(dog, state.lovedDog)
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.4.0-SNAPSHOT
VERSION_NAME=2.4.0
GROUP=com.airbnb.android
POM_DESCRIPTION=Mavericks is an Android application framework that makes product development fast and fun.
POM_URL=https://github.com/airbnb/mavericks
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ internal class HelloDaggerViewModelTest {
@get:Rule
val mvrxRule = MvRxTestRule()


@Test
fun `fetches message when created`() {
fun `fetches message when created`() {
val repo = mockk<HelloRepository> {
every { sayHello() } returns flowOf("Hello!")
}
Expand All @@ -26,4 +25,4 @@ internal class HelloDaggerViewModelTest {
assertEquals(Success("Hello!"), state.message)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ class MavericksLauncherFragment : MavericksLauncherBaseFragment() {
}
}

private fun EpoxyController.addMocksForSelectedView(state: MavericksLauncherState, mocksToShow: List<MockedViewProvider<*>>?, context: Context) {
private fun EpoxyController.addMocksForSelectedView(
state: MavericksLauncherState,
mocksToShow: List<MockedViewProvider<*>>?,
context: Context
) {
if (mocksToShow == null || mocksToShow.isEmpty()) {
textRow {
id("no mocks")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ interface DataClassSetDsl {
/**
* A shortcut to setting an Async property to Loading, instead of "data.set { ::property }.with { Loading() }".
*/
fun <DataClass : Any, Type : Async<AsyncType>, AsyncType> DataClass.setLoading(block: DataClass.() -> KProperty0<Type>): DataClass {
fun <DataClass : Any, Type : Async<AsyncType>, AsyncType> DataClass.setLoading(
block: DataClass.() -> KProperty0<Type>
): DataClass {
return Setter<DataClass, Async<AsyncType>?>(this, block()).with { Loading() }
}

/**
* A shortcut to setting an Async property to Fail, instead of "data.set { ::property }.with { Fail() }".
*/
fun <DataClass : Any, Type : Async<AsyncType>, AsyncType> DataClass.setNetworkFailure(block: DataClass.() -> KProperty0<Type>): DataClass {
fun <DataClass : Any, Type : Async<AsyncType>, AsyncType> DataClass.setNetworkFailure(
block: DataClass.() -> KProperty0<Type>
): DataClass {
return Setter<DataClass, Async<AsyncType>?>(this, block()).with { Fail(Throwable("Network request failed")) }
}

Expand Down Expand Up @@ -125,7 +129,10 @@ interface DataClassSetDsl {
/**
* Helper to copy a nested class and update a property on it.
*/
class Setter<DataClass : Any, PropType>(private val instance: DataClass, internal val property: KProperty0<PropType>) {
class Setter<DataClass : Any, PropType>(
private val instance: DataClass,
internal val property: KProperty0<PropType>
) {
init {
val clazz = instance::class
if (instance is Async<*>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ class MockableMavericksViewModelConfig<S : MavericksState>(
updateStateStore()
}

fun addOnExecuteListener(listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit) {
fun addOnExecuteListener(
listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit
) {
onExecuteListeners.add(listener)
}

fun removeOnExecuteListener(listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit) {
fun removeOnExecuteListener(
listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit
) {
onExecuteListeners.remove(listener)
}

Expand Down Expand Up @@ -300,12 +304,16 @@ open class MockMavericksViewModelConfigFactory(
/**
* Add a lambda that will be invoked whenever [MavericksViewModel.execute] is used.
*/
fun addOnExecuteListener(listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit) {
fun addOnExecuteListener(
listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit
) {
onExecuteListeners.add(listener)
mockConfigs.values.forEach { it.addOnExecuteListener(listener) }
}

fun removeOnExecuteListener(listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit) {
fun removeOnExecuteListener(
listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit
) {
onExecuteListeners.remove(listener)
mockConfigs.values.forEach { it.removeOnExecuteListener(listener) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class AutoValueTypePrinterTest : BaseTest() {
"val mockAutoValue_AutoValueClass by lazy { AutoValueClass.builder()\n" +
".setName(\"foo\")\n" +
".setNumberOfLegs(1)\n" +
".build() }", constructorCode.lazyPropertyToCreateObject
".build() }",
constructorCode.lazyPropertyToCreateObject
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ abstract class BaseTest {
}
.commitNow()


return controller
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,18 @@ class ConstructorCodeGeneratorTest : BaseTest() {
).expect("ConstructorCodeGeneratorTest.Test(list=arrayOf(1,2,3,4))")
}

private fun <T : MavericksState> com.airbnb.mvrx.mocking.printer.ConstructorCodeGenerator<T>.expect(expectedCode: String) {
private fun <T : MavericksState> com.airbnb.mvrx.mocking.printer.ConstructorCodeGenerator<T>.expect(
expectedCode: String
) {
assertEquals("valmockTestbylazy{$expectedCode}", lazyPropertyToCreateObject.removeWhiteSpace())
}

data class StateWithJsonObject(val json: String = """{"color":"red","numbers":[{"favorite":7},{"lowest":0}]}""") :
MavericksState

data class StateWithInvalidJsonObject(val json: String = """not valid{"color":"red","numbers":[{"favorite":7},{"lowest":0}]}""") :
data class StateWithInvalidJsonObject(
val json: String = """not valid{"color":"red","numbers":[{"favorite":7},{"lowest":0}]}"""
) :
MavericksState

data class StateWithJsonArray(val json: String = """[{"favorite":7},{"lowest":0}]""") :
Expand Down Expand Up @@ -268,4 +272,4 @@ private fun String.removeWhiteSpace(): String {
.replace("\n", "")
.replace("\r", "")
.replace("\t", "")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.test.TestCoroutineDispatcher

fun testCoroutineScope() = CoroutineScope(SupervisorJob() + TestCoroutineDispatcher())
fun testCoroutineScope() = CoroutineScope(SupervisorJob() + TestCoroutineDispatcher())
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ data class TestClass2(

data class TestClass3(
val str: String = ""
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ class MavericksViewModelConfigTest : BaseTest() {
class TestViewModel : MavericksViewModel<TestState>(TestState())

data class TestState(val num: Int = 0) : MavericksState
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class MockStateHolderTest : BaseTest() {
defaultState = defaultState,
defaultArgs = null
) {

}
}
else -> MavericksViewMocks.DefaultViewMocksProvider.mavericksViewMocks(view)
Expand Down Expand Up @@ -220,7 +219,6 @@ class MockStateHolderTest : BaseTest() {
defaultState = TestState(num = 4),
defaultArgs = null
) {

}
}
else -> MavericksViewMocks.DefaultViewMocksProvider.mavericksViewMocks(view)
Expand Down Expand Up @@ -253,7 +251,6 @@ class MockStateHolderTest : BaseTest() {
defaultState = TestState(num = 3),
defaultArgs = null
) {

}
}

Expand All @@ -266,4 +263,4 @@ class MockStateHolderTest : BaseTest() {

data class TestState(val num: Int = 0) : MavericksState
class FragmentVM(initialState: TestState) : MavericksViewModel<TestState>(initialState)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ class MockableMavericksStateStoreTest : BaseTest() {
}

private data class TestState(val num: Int = 0) : MavericksState
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ open class TestActivity : AppCompatActivity() {
}
}

const val CONTAINER_ID = 111
const val CONTAINER_ID = 111
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ class ViewModelBlockExecutionTest : BaseTest() {
}
}

fun <S : MavericksState, VM : MavericksViewModel<S>> VM.state(): S = config.stateStore.state
fun <S : MavericksState, VM : MavericksViewModel<S>> VM.state(): S = config.stateStore.state
Loading

0 comments on commit 6b3c971

Please sign in to comment.