mirror of
https://github.com/kickstarter/android-oss.git
synced 2026-03-13 09:11:01 +08:00
MBL-2613: Upgrade Kotlin & Compose Compiler (#2401)
* upgrade gradle via distributionUrl * wip: upgrade kotlin via gradle plugin & compose gradle plugin * wip: disable k2 impl of kapt compiler plugin * wip: fix argument type mismatch and toLowercase() deprecated * wip: fix toUppercase() deprecated * wip: unmark TestApplicationModule as `@Module` --------- Co-authored-by: Tony Teate <4317686+tonyteate@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@ buildscript {
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'org.jetbrains.kotlin.plugin.compose'
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
@@ -146,10 +147,6 @@ android {
|
||||
buildConfig true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion "$compose_version"
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
jniLibs {
|
||||
useLegacyPackaging = true
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.net.URL
|
||||
* @param <Envelope> The type of envelope the API returns for a list of data, e.g. `DiscoverEnvelope`.
|
||||
* @param <Params> The type of params that [ApiClientType] can use to make a request. Many times this can just be `Void`.
|
||||
</Params></Envelope></Data> */
|
||||
class ApiPaginatorV2<Data, Envelope, Params> private constructor(
|
||||
class ApiPaginatorV2<Data, Envelope : Any, Params : Any> private constructor(
|
||||
private val nextPage: Observable<Unit>,
|
||||
private val startOverWith: Observable<Params>?,
|
||||
private val envelopeToListOfData: Function<Envelope, List<Data>>,
|
||||
@@ -57,7 +57,7 @@ class ApiPaginatorV2<Data, Envelope, Params> private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
class Builder<Data, Envelope, Params> {
|
||||
class Builder<Data, Envelope : Any, Params : Any> {
|
||||
private lateinit var nextPage: Observable<Unit>
|
||||
private var startOverWith: Observable<Params>? = null
|
||||
private lateinit var envelopeToListOfData: Function<Envelope, List<Data>>
|
||||
@@ -66,7 +66,7 @@ class ApiPaginatorV2<Data, Envelope, Params> private constructor(
|
||||
private lateinit var envelopeToMoreUrl: Function<Envelope, String>
|
||||
private var pageTransformation: Function<List<Data>, List<Data>>? = null
|
||||
private var clearWhenStartingOver = false
|
||||
private var concater =
|
||||
private var concater: BiFunction<List<Data>, List<Data>, List<Data>> =
|
||||
BiFunction { xs: List<Data>, ys: List<Data> -> ListUtils.concat(xs, ys) }
|
||||
private var distinctUntilChanged = false
|
||||
|
||||
@@ -255,7 +255,7 @@ class ApiPaginatorV2<Data, Envelope, Params> private constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun <Data, Envelope, FirstPageParams> builder(): Builder<Data, Envelope, FirstPageParams> {
|
||||
fun <Data, Envelope : Any, FirstPageParams : Any> builder(): Builder<Data, Envelope, FirstPageParams> {
|
||||
return Builder()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.reactivex.Observable
|
||||
import io.reactivex.ObservableSource
|
||||
import io.reactivex.ObservableTransformer
|
||||
|
||||
class TakeWhenTransformerV2<S, T>(private val `when`: Observable<T>) : ObservableTransformer<S, S> {
|
||||
class TakeWhenTransformerV2<S : Any, T>(private val `when`: Observable<T>) : ObservableTransformer<S, S> {
|
||||
override fun apply(upstream: Observable<S>): ObservableSource<S> {
|
||||
return `when`.withLatestFrom(upstream) { t: T, x: S -> x }
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ fun TextView.makeLinks(vararg links: Pair<String, View.OnClickListener>, @ColorR
|
||||
}
|
||||
}
|
||||
|
||||
startIndexOfLink = this.text.toString().toLowerCase(Locale.getDefault()).indexOf(link.first.toLowerCase(Locale.getDefault()), startIndexOfLink + 1)
|
||||
startIndexOfLink = this.text.toString().lowercase(Locale.getDefault())
|
||||
.indexOf(link.first.lowercase(Locale.getDefault()), startIndexOfLink + 1)
|
||||
|
||||
if (startIndexOfLink == -1) continue // todo if you want to verify your texts contains links text
|
||||
|
||||
|
||||
@@ -6,38 +6,28 @@ import android.content.SharedPreferences
|
||||
import android.content.res.AssetManager
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.kickstarter.libs.qualifiers.ApplicationContext
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
// TODO: Refactor the approach to testing with this class to not rely on extending `ApplicationModule`.
|
||||
/* This class is no longer marked as `@Module`, and methods no longer marked as
|
||||
* `@Provides`. Dagger 2 recognizes this approach as an anti-pattern, and since Kotlin 1.9.+
|
||||
* overriding `@Provides` methods becomes a compile-time error. */
|
||||
class TestApplicationModule(private val application: Application) : ApplicationModule(application) {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Override
|
||||
override fun provideApplication(): Application {
|
||||
return application
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@ApplicationContext
|
||||
@Override
|
||||
override fun provideApplicationContext(): Context {
|
||||
return application
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Override
|
||||
override fun provideAssetManager(): AssetManager {
|
||||
return application.assets
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Override
|
||||
override fun provideSharedPreferences(): SharedPreferences {
|
||||
return PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext())
|
||||
|
||||
@@ -14,7 +14,7 @@ class WebUtilsTest : KSRobolectricTestCase() {
|
||||
|
||||
val packageInfo = packageManager.getPackageInfo(context().applicationContext.packageName, 0)
|
||||
val variant = StringBuilder().append(BuildConfig.FLAVOR)
|
||||
.append(BuildConfig.BUILD_TYPE.substring(0, 1).toUpperCase(Locale.US))
|
||||
.append(BuildConfig.BUILD_TYPE.substring(0, 1).uppercase(Locale.US))
|
||||
.append(BuildConfig.BUILD_TYPE.substring(1))
|
||||
.toString()
|
||||
val versionCode = packageInfo.versionCode
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.8.10'
|
||||
ext.kotlin_version = '2.1.21'
|
||||
ext.jacoco_version = '0.8.8'
|
||||
|
||||
repositories {
|
||||
@@ -10,9 +10,10 @@ buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.12.0'
|
||||
classpath 'com.google.gms:google-services:4.4.3'
|
||||
classpath "com.google.firebase:perf-plugin:2.0.0"
|
||||
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "com.google.firebase:perf-plugin:2.0.0"
|
||||
classpath "org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,3 +17,5 @@ android.useAndroidX=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
#android.debug.obsoleteApi=true
|
||||
|
||||
kapt.use.k2=false
|
||||
7
gradle/wrapper/gradle-wrapper.properties
vendored
7
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,7 @@
|
||||
#Wed Jan 26 16:41:20 PST 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Reference in New Issue
Block a user