diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 15bd8fa2..621f8b55 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -11,6 +11,10 @@ jobs: steps: - name: Checkout mavericks uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' - name: Detekt run: "./gradlew detekt -PCI=true" lint: @@ -18,6 +22,10 @@ jobs: steps: - name: Checkout mavericks uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' - name: Lint run: "./gradlew lintRelease" test-coverage: @@ -26,6 +34,10 @@ jobs: steps: - name: Checkout mavericks uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' - name: Unit Tests run: "./gradlew testReleaseUnitTest" - name: Code Coverage diff --git a/build.gradle b/build.gradle index ddb8a9eb..fc960490 100644 --- a/build.gradle +++ b/build.gradle @@ -52,7 +52,7 @@ subprojects { project -> if (project.hasProperty("android")) { android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { // Allow projects to override this. diff --git a/gradle.properties b/gradle.properties index 5330148e..36280ec1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,3 +22,6 @@ android.useAndroidX=true # With the default memory size Gradle gets out of memory issues when building, so we have to increase it # Dokka fails without a larger metaspace https://github.com/Kotlin/dokka/issues/1405 org.gradle.jvmargs=-Xms128m -Xmx4096m -XX:MaxMetaspaceSize=2g +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8e58e39a..6085a008 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ # 5. Make sure it is using the version you want [plugins] -ksp = { id = "com.google.devtools.ksp", version = "1.7.10-1.0.6" } +ksp = { id = "com.google.devtools.ksp", version = "1.8.22-1.0.11" } [libraries] androidGradle = "com.android.tools.build:gradle:_" @@ -43,10 +43,11 @@ fragmentKtx = "androidx.fragment:fragment-ktx:_" fragmentTesting = "androidx.fragment:fragment-testing:_" koin = "io.insert-koin:koin-android:_" kotlinGradle = "org.jetbrains.kotlin:kotlin-gradle-plugin:_" -kotlin = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:_" +kotlin = "org.jetbrains.kotlin:kotlin-stdlib:_" kotlinCoroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:_" kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect:_" lifecycleCommon = "androidx.lifecycle:lifecycle-common-java8:_" +lifecycleTest = "androidx.lifecycle:lifecycle-runtime-testing:_" lottie = "com.airbnb.android:lottie:_" moshi = "com.squareup.moshi:moshi:_" moshiCodegen = "com.squareup.moshi:moshi-kotlin-codegen:_" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c0..943f0cbf 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 31cca491..17a8ddce 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0c..65dcd68d 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,105 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index ac1b06f9..6689b85b 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/mvrx-compose/build.gradle b/mvrx-compose/build.gradle index b83406f4..4b10088c 100644 --- a/mvrx-compose/build.gradle +++ b/mvrx-compose/build.gradle @@ -21,12 +21,13 @@ android { minSdkVersion 21 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - packagingOptions { - exclude 'META-INF/LGPL2.1' - exclude 'META-INF/AL2.0' + resources { + excludes += ['META-INF/LGPL2.1', 'META-INF/AL2.0'] + } } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -50,6 +51,7 @@ android { includeAndroidResources = true } } + namespace 'com.airbnb.mvrx.compose' } dependencies { diff --git a/mvrx-compose/src/main/AndroidManifest.xml b/mvrx-compose/src/main/AndroidManifest.xml index c940d1a9..cc947c56 100644 --- a/mvrx-compose/src/main/AndroidManifest.xml +++ b/mvrx-compose/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/mvrx-compose/src/main/kotlin/com/airbnb/mvrx/compose/MavericksComposeExtensions.kt b/mvrx-compose/src/main/kotlin/com/airbnb/mvrx/compose/MavericksComposeExtensions.kt index 73e3117b..cacbaed9 100644 --- a/mvrx-compose/src/main/kotlin/com/airbnb/mvrx/compose/MavericksComposeExtensions.kt +++ b/mvrx-compose/src/main/kotlin/com/airbnb/mvrx/compose/MavericksComposeExtensions.kt @@ -49,6 +49,7 @@ import kotlin.reflect.KProperty1 * initialized. This will supersede any arguments from the fragment or activity. */ @Composable +@Suppress("DEPRECATION") inline fun , reified S : MavericksState> mavericksViewModel( scope: LifecycleOwner = LocalLifecycleOwner.current, noinline keyFactory: (() -> String)? = null, diff --git a/mvrx-compose/src/test/AndroidManifest.xml b/mvrx-compose/src/test/AndroidManifest.xml index a3f5d0e0..bcd868b6 100644 --- a/mvrx-compose/src/test/AndroidManifest.xml +++ b/mvrx-compose/src/test/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> + diff --git a/mvrx-launcher/build.gradle b/mvrx-launcher/build.gradle index 8784bbfe..90fd2ca5 100644 --- a/mvrx-launcher/build.gradle +++ b/mvrx-launcher/build.gradle @@ -25,6 +25,7 @@ android { includeAndroidResources = true } } + namespace 'com.airbnb.mvrx.launcher' } dependencies { diff --git a/mvrx-launcher/src/main/AndroidManifest.xml b/mvrx-launcher/src/main/AndroidManifest.xml index 5d8d5dcc..ead95e0c 100644 --- a/mvrx-launcher/src/main/AndroidManifest.xml +++ b/mvrx-launcher/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/mvrx-mocking/build.gradle b/mvrx-mocking/build.gradle index eeaf9fe1..a23c2fc3 100644 --- a/mvrx-mocking/build.gradle +++ b/mvrx-mocking/build.gradle @@ -34,6 +34,7 @@ android { } } } + namespace 'com.airbnb.mvrx.mocking' } dependencies { diff --git a/mvrx-mocking/src/main/AndroidManifest.xml b/mvrx-mocking/src/main/AndroidManifest.xml index 3e24fa5f..cc947c56 100644 --- a/mvrx-mocking/src/main/AndroidManifest.xml +++ b/mvrx-mocking/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/mvrx-navigation/build.gradle b/mvrx-navigation/build.gradle index a48f37cb..24aab898 100644 --- a/mvrx-navigation/build.gradle +++ b/mvrx-navigation/build.gradle @@ -31,6 +31,7 @@ android { } } } + namespace 'com.airbnb.mvrx.navigation' } dependencies { diff --git a/mvrx-navigation/src/main/AndroidManifest.xml b/mvrx-navigation/src/main/AndroidManifest.xml index 45fc96e0..cc947c56 100644 --- a/mvrx-navigation/src/main/AndroidManifest.xml +++ b/mvrx-navigation/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/mvrx-rxjava2/build.gradle b/mvrx-rxjava2/build.gradle index c3994feb..65ef320b 100644 --- a/mvrx-rxjava2/build.gradle +++ b/mvrx-rxjava2/build.gradle @@ -28,6 +28,7 @@ android { } } } + namespace 'com.airbnb.mvrx.rxjava2' } dependencies { @@ -44,4 +45,5 @@ dependencies { testImplementation libs.kotlinCoroutinesTest testImplementation libs.mockito testImplementation libs.roboeletric + testImplementation libs.lifecycleTest } diff --git a/mvrx-rxjava2/src/main/AndroidManifest.xml b/mvrx-rxjava2/src/main/AndroidManifest.xml index 7c6f5198..82193193 100644 --- a/mvrx-rxjava2/src/main/AndroidManifest.xml +++ b/mvrx-rxjava2/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + diff --git a/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/BaseMvRxViewModel.kt b/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/BaseMvRxViewModel.kt index 971a711d..8ab322f2 100644 --- a/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/BaseMvRxViewModel.kt +++ b/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/BaseMvRxViewModel.kt @@ -47,7 +47,10 @@ abstract class BaseMvRxViewModel( * This is not publicly accessible as it should only be used to control subscriptions * between two view models. */ - private val lifecycleOwner: LifecycleOwner = LifecycleOwner { lifecycleRegistry } + private val lifecycleOwner: LifecycleOwner = object : LifecycleOwner { + override val lifecycle: Lifecycle + get() = lifecycleRegistry + } /** * Since lifecycle 2.3.0, it enforces calls from the main thread. Mavericks owns this registry so it can enforce that to be the case. diff --git a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt deleted file mode 100644 index 91dfc446..00000000 --- a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.airbnb.mvrx - -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry - -class TestLifecycleOwner : LifecycleOwner { - - private val _lifecycle = LifecycleRegistry(this) - - override fun getLifecycle(): LifecycleRegistry = _lifecycle -} diff --git a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/ViewModelSubscriberTest.kt b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/ViewModelSubscriberTest.kt index 615c1b7d..bf1f473a 100644 --- a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/ViewModelSubscriberTest.kt +++ b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/ViewModelSubscriberTest.kt @@ -2,6 +2,7 @@ package com.airbnb.mvrx import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.testing.TestLifecycleOwner import io.reactivex.Completable import io.reactivex.Maybe import io.reactivex.Observable diff --git a/mvrx-testing/build.gradle b/mvrx-testing/build.gradle index 75c91bff..4fe290de 100644 --- a/mvrx-testing/build.gradle +++ b/mvrx-testing/build.gradle @@ -22,13 +22,13 @@ android { multiDexEnabled true consumerProguardFiles "proguard-rules.pro" } - packagingOptions { - exclude 'META-INF/AL2.0' - exclude 'META-INF/LGPL2.1' - exclude 'META-INF/LICENSE.md' - exclude 'META-INF/LICENSE-notice.md' + resources { + excludes += ['META-INF/AL2.0', 'META-INF/LGPL2.1', 'META-INF/LICENSE.md', 'META-INF/LICENSE-notice.md'] + } } + + namespace 'com.airbnb.mvrx.test' } dependencies { diff --git a/mvrx-testing/src/main/AndroidManifest.xml b/mvrx-testing/src/main/AndroidManifest.xml index 8882fb49..cc947c56 100644 --- a/mvrx-testing/src/main/AndroidManifest.xml +++ b/mvrx-testing/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/mvrx/build.gradle b/mvrx/build.gradle index 6cbbbc77..f6c35c72 100644 --- a/mvrx/build.gradle +++ b/mvrx/build.gradle @@ -34,6 +34,7 @@ android { } } } + namespace 'com.airbnb.mvrx' } dependencies { @@ -53,4 +54,5 @@ dependencies { testImplementation libs.kotlinCoroutinesTest testImplementation libs.mockito testImplementation libs.roboeletric + testImplementation libs.lifecycleTest } diff --git a/mvrx/src/main/AndroidManifest.xml b/mvrx/src/main/AndroidManifest.xml index 873ea27c..82193193 100644 --- a/mvrx/src/main/AndroidManifest.xml +++ b/mvrx/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksExtensions.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksExtensions.kt index d2276edd..b315c939 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksExtensions.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksExtensions.kt @@ -14,7 +14,7 @@ import kotlin.reflect.KProperty * * Looks for [Mavericks.KEY_ARG] on the arguments of the fragments. */ -@Suppress("FunctionName") +@Suppress("FunctionName", "DEPRECATION") @InternalMavericksApi fun T._fragmentArgsProvider(): Any? = arguments?.get(Mavericks.KEY_ARG) @@ -208,6 +208,7 @@ inline fun , reified S : MavericksState> T * This is similar to [fragmentViewModel] and [actvityViewModel] but used when a view model * is accessed directly from an activity itself. */ +@Suppress("DEPRECATION") inline fun , reified S : MavericksState> T.viewModel( viewModelClass: KClass = VM::class, crossinline keyFactory: () -> String = { viewModelClass.java.name } @@ -232,6 +233,7 @@ inline fun , reified S : MavericksState> T fun args() = object : ReadOnlyProperty { var value: V? = null + @Suppress("DEPRECATION") override fun getValue(thisRef: Fragment, property: KProperty<*>): V { if (value == null) { val args = thisRef.arguments @@ -262,6 +264,7 @@ fun argsOrNull() = object : ReadOnlyProperty { var value: V? = null var read: Boolean = false + @Suppress("DEPRECATION") override fun getValue(thisRef: Fragment, property: KProperty<*>): V? { if (!read) { val args = thisRef.arguments diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelProvider.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelProvider.kt index 8b0d0a37..71d5e934 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelProvider.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelProvider.kt @@ -11,7 +11,6 @@ import java.io.Serializable * Helper ViewModelProvider that has a single method for taking either a [Fragment] or [ComponentActivity] instead * of two separate ones. The logic for providing the correct scope is inside the method. */ -@InternalMavericksApi object MavericksViewModelProvider { /** * Mavericks specific ViewModelProvider used for creating a BaseMavericksViewModel scoped to either a [Fragment] or [ComponentActivity]. @@ -28,6 +27,7 @@ object MavericksViewModelProvider { * @param initialStateFactory A way to specify how to create the initial state, can be mocked out for testing. * */ + @InternalMavericksApi fun , S : MavericksState> get( viewModelClass: Class, stateClass: Class, diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/LifecycleAwareLazyTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/LifecycleAwareLazyTest.kt index 7ebe5d57..3fd13a84 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/LifecycleAwareLazyTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/LifecycleAwareLazyTest.kt @@ -1,6 +1,7 @@ package com.airbnb.mvrx import androidx.lifecycle.Lifecycle +import androidx.lifecycle.testing.TestLifecycleOwner import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -14,13 +15,12 @@ class LifecycleAwareLazyTest : BaseTest() { @Before fun setup() { - owner = TestLifecycleOwner() + owner = TestLifecycleOwner(Lifecycle.State.INITIALIZED) lazyProp = lifecycleAwareLazy(owner) { "Hello World" } } @Test fun testNotInitializedBeforeOnCreate() { - owner.lifecycle.currentState = Lifecycle.State.INITIALIZED assertFalse(lazyProp.isInitialized()) } @@ -69,13 +69,12 @@ class LifecycleAwareLazyTest : BaseTest() { alreadyCreatedOwner.lifecycle.currentState = Lifecycle.State.CREATED val createdLazy = lifecycleAwareLazy(alreadyCreatedOwner) { "Hello World" } assertTrue(createdLazy.isInitialized()) - assertEquals(0, alreadyCreatedOwner.observerAddedCount) + assertEquals(0, alreadyCreatedOwner.observerCount) } @Test fun testOneObserverIsAddedIfStateIsInitialized() { - owner.lifecycle.currentState = Lifecycle.State.INITIALIZED assertFalse(lazyProp.isInitialized()) - assertEquals(1, owner.observerAddedCount) + assertEquals(1, owner.observerCount) } } diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlowKtTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlowKtTest.kt index b3dfb872..2aab5184 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlowKtTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlowKtTest.kt @@ -1,6 +1,7 @@ package com.airbnb.mvrx import androidx.lifecycle.Lifecycle +import androidx.lifecycle.testing.TestLifecycleOwner import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collect @@ -20,7 +21,7 @@ class MavericksLifecycleAwareFlowKtTest : BaseTest() { @Test fun testDoesntFlowFromCreate() = runTest(UnconfinedTestDispatcher()) { val flow = flowOf(1) - val owner = TestLifecycleOwner() + val owner = TestLifecycleOwner(Lifecycle.State.CREATED) val values = mutableListOf() val job = flow.flowWhenStarted(owner).onEach { values += it diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt deleted file mode 100644 index aea7c26a..00000000 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.airbnb.mvrx - -import androidx.lifecycle.LifecycleObserver -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry - -class TestLifecycleOwner : LifecycleOwner { - - var observerAddedCount = 0 - - private val _lifecycle = object : LifecycleRegistry(this) { - override fun addObserver(observer: LifecycleObserver) { - observerAddedCount += 1 - super.addObserver(observer) - } - } - - override fun getLifecycle(): LifecycleRegistry = _lifecycle -} diff --git a/sample-anvil/build.gradle b/sample-anvil/build.gradle index 11bc5a87..812f3489 100644 --- a/sample-anvil/build.gradle +++ b/sample-anvil/build.gradle @@ -32,6 +32,7 @@ android { buildFeatures { viewBinding true } + namespace 'com.airbnb.mvrx.sample.anvil' } dependencies { diff --git a/sample-anvil/src/main/AndroidManifest.xml b/sample-anvil/src/main/AndroidManifest.xml index 8554bdb5..661aeb94 100644 --- a/sample-anvil/src/main/AndroidManifest.xml +++ b/sample-anvil/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> + xmlns:tools="http://schemas.android.com/tools"> - + + xmlns:tools="http://schemas.android.com/tools"> - + diff --git a/sample-hilt/build.gradle b/sample-hilt/build.gradle index b397c537..cbea9816 100644 --- a/sample-hilt/build.gradle +++ b/sample-hilt/build.gradle @@ -21,6 +21,7 @@ android { buildFeatures { viewBinding true } + namespace 'com.airbnb.mvrx.hellohilt' } dependencies { diff --git a/sample-hilt/src/main/AndroidManifest.xml b/sample-hilt/src/main/AndroidManifest.xml index 7d035c68..2b7a5301 100644 --- a/sample-hilt/src/main/AndroidManifest.xml +++ b/sample-hilt/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> - + - + diff --git a/utils-view-binding/build.gradle b/utils-view-binding/build.gradle index b0fec031..6481ddc6 100644 --- a/utils-view-binding/build.gradle +++ b/utils-view-binding/build.gradle @@ -5,6 +5,7 @@ android { buildFeatures { viewBinding true } + namespace 'com.airbnb.mvrx.viewbinding' } dependencies { diff --git a/utils-view-binding/src/main/AndroidManifest.xml b/utils-view-binding/src/main/AndroidManifest.xml index 474d85ea..568741e5 100644 --- a/utils-view-binding/src/main/AndroidManifest.xml +++ b/utils-view-binding/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/versions.properties b/versions.properties index 43d2768b..ebcba689 100644 --- a/versions.properties +++ b/versions.properties @@ -75,20 +75,7 @@ version.mockito=4.6.1 version.kotlinx.coroutines=1.6.4 ## # available=1.7.0-Beta -version.kotlin=1.7.10 -## # available=1.7.20-Beta -## # available=1.7.20-RC -## # available=1.7.20 -## # available=1.7.21 -## # available=1.7.22 -## # available=1.8.0-Beta -## # available=1.8.0-RC -## # available=1.8.0-RC2 -## # available=1.8.0 -## # available=1.8.10 -## # available=1.8.20-Beta -## # available=1.8.20-RC -## # available=1.8.20-RC2 +version.kotlin=1.8.22 version.koin=3.2.0 ### available=3.2.1 @@ -236,27 +223,11 @@ version.androidx.navigation=2.5.1 version.androidx.multidex=2.0.1 -version.androidx.lifecycle-viewmodel-compose=2.5.1 -## # available=2.6.0-alpha01 -## # available=2.6.0-alpha02 -## # available=2.6.0-alpha03 -## # available=2.6.0-alpha04 -## # available=2.6.0-alpha05 -## # available=2.6.0-beta01 -## # available=2.6.0-rc01 -## # available=2.6.0 -## # available=2.6.1 - -version.androidx.lifecycle=2.5.1 -## # available=2.6.0-alpha01 -## # available=2.6.0-alpha02 -## # available=2.6.0-alpha03 -## # available=2.6.0-alpha04 -## # available=2.6.0-alpha05 -## # available=2.6.0-beta01 -## # available=2.6.0-rc01 -## # available=2.6.0 -## # available=2.6.1 +version.androidx.lifecycle-viewmodel-compose=2.6.1 + +version.androidx.lifecycle=2.6.1 + +version.androidx.lifecycle-runtime-testing=2.6.1 version.androidx.fragment=1.5.2 ## # available=1.5.3 @@ -370,7 +341,7 @@ version.androidx.compose.foundation=1.2.1 ## # available=1.5.0-alpha01 ## unused -version.androidx.compose.compiler=1.3.0 +version.androidx.compose.compiler=1.4.8 version.androidx.cardview=1.0.0 @@ -413,74 +384,6 @@ plugin.io.gitlab.arturbosch.detekt=1.21.0 ## # available=1.22.0-RC3 ## # available=1.22.0 -version.anvil=2.4.2 -### available=2.4.3 -### available=2.4.3-1-8-0-RC -### available=2.4.4 -### available=2.4.4-1.8.20-RC - -plugin.android=7.2.2 -## # available=7.3.0-alpha01 -## # available=7.3.0-alpha02 -## # available=7.3.0-alpha03 -## # available=7.3.0-alpha04 -## # available=7.3.0-alpha05 -## # available=7.3.0-alpha06 -## # available=7.3.0-alpha07 -## # available=7.3.0-alpha08 -## # available=7.3.0-alpha09 -## # available=7.3.0-beta01 -## # available=7.3.0-beta02 -## # available=7.3.0-beta03 -## # available=7.3.0-beta04 -## # available=7.3.0-beta05 -## # available=7.3.0-rc01 -## # available=7.3.0 -## # available=7.3.1 -## # available=7.4.0-alpha01 -## # available=7.4.0-alpha02 -## # available=7.4.0-alpha03 -## # available=7.4.0-alpha04 -## # available=7.4.0-alpha05 -## # available=7.4.0-alpha06 -## # available=7.4.0-alpha07 -## # available=7.4.0-alpha08 -## # available=7.4.0-alpha09 -## # available=7.4.0-alpha10 -## # available=7.4.0-beta01 -## # available=7.4.0-beta02 -## # available=7.4.0-beta03 -## # available=7.4.0-beta04 -## # available=7.4.0-beta05 -## # available=7.4.0-rc01 -## # available=7.4.0-rc02 -## # available=7.4.0-rc03 -## # available=7.4.0 -## # available=7.4.1 -## # available=7.4.2 -## # available=8.0.0-alpha01 -## # available=8.0.0-alpha02 -## # available=8.0.0-alpha03 -## # available=8.0.0-alpha04 -## # available=8.0.0-alpha05 -## # available=8.0.0-alpha06 -## # available=8.0.0-alpha07 -## # available=8.0.0-alpha08 -## # available=8.0.0-alpha09 -## # available=8.0.0-alpha10 -## # available=8.0.0-alpha11 -## # available=8.0.0-beta01 -## # available=8.0.0-beta02 -## # available=8.0.0-beta03 -## # available=8.0.0-beta04 -## # available=8.0.0-beta05 -## # available=8.1.0-alpha01 -## # available=8.1.0-alpha02 -## # available=8.1.0-alpha03 -## # available=8.1.0-alpha04 -## # available=8.1.0-alpha05 -## # available=8.1.0-alpha06 -## # available=8.1.0-alpha07 -## # available=8.1.0-alpha08 -## # available=8.1.0-alpha09 -## # available=8.1.0-alpha10 +version.anvil=2.4.6 + +plugin.android=8.1.0