Skip to content

Commit

Permalink
Kotlin 1.9.20 + AGP 8.2.0-rc03 + new Wasm targets
Browse files Browse the repository at this point in the history
  • Loading branch information
romainbsl committed Nov 17, 2023
1 parent 5caf410 commit d8f9e3d
Show file tree
Hide file tree
Showing 56 changed files with 490 additions and 710 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- name: Check out
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3
- name: Cached Konan
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 #v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-konan-
- name: Cached Gradle
uses: gradle/gradle-build-action@v2
- name: Set up JDK 11
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 #v2
- name: Set up JDK 17
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc #v3
with:
java-version: 11
distribution: temurin
java-version: 17
distribution: 'temurin'
# Host only for MacOS / Windows
- name: Check (macos / windows)
if: matrix.os != 'ubuntu-latest'
run: ./gradlew hostOnlyTest
shell: bash
- name: Check Android
if: matrix.os == 'macOS-latest'
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 #v2
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #v2.28.0
with:
api-level: 29
ndk: 21.3.6528147
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ jobs:
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-konan-
- name: Cached Gradle
uses: gradle/gradle-build-action@v2
- name: Set up JDK 11
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 #v2
- name: Set up JDK 17
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc #v3
with:
java-version: 11
distribution: temurin
java-version: 17
distribution: 'temurin'
# Host only for MacOS / Windows
- name: Check (macos / windows)
if: matrix.os != 'ubuntu-latest'
run: ./gradlew hostOnlyTest
shell: bash
- name: Check Android
if: matrix.os == 'macOS-latest'
uses: reactivecircus/android-emulator-runner@50986b1464923454c95e261820bc626f38490ec0 #v2
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #v2.28.0
with:
api-level: 29
ndk: 21.3.6528147
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- name: Check out
uses: actions/checkout@v2
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
- name: Cached Konan
uses: actions/cache@v2
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 #v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-konan-
- name: Cached Gradle
uses: gradle/gradle-build-action@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 #v2
- name: Set up JDK 17
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc #v3
with:
java-version: 11
java-version: 17
distribution: 'temurin'
- name: Check
run: ./gradlew check
shell: bash
32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/kosi-libs/Kodein/blob/master/LICENSE.txt)
[![Slack channel](https://img.shields.io/badge/Chat-Slack-green.svg?style=flat&logo=slack)](https://kotlinlang.slack.com/messages/kodein/)


KOtlin DEpendency INjection
===========================

Expand Down Expand Up @@ -55,15 +54,12 @@ class Controller(private di: DI) {
- It is fast and optimized (makes extensive use of `inline`)
- It can be used in plain Java

### Looking for **KODEIN 7.0** migration guide?
> Follow this us [here](https://kosi-libs.org/kodein/7.16/migration/migration-6to7.html).
Kotlin & JVM compatibility
---------

| Kodein | Kotlin | JDK | Compose |
|:-----------:|:------:|:-------:|:------------------:|
| 7.21.0 | 1.8.20 | min 1.8 | Compatible |
| 7.21.0 | 1.8.20 | min 17 | Compatible |
| 7.20.1 | 1.8.10 | min 1.8 | Compatible |
| 7.19.0 | 1.8.10 | min 1.8 | Compatible |
| 7.18.0 | 1.8.0 | min 1.8 | Compatible |
Expand Down Expand Up @@ -94,10 +90,6 @@ Kotlin & JVM compatibility
| 4.1+ | 1.1.3 | 1.6 | - |
| 4.0.0-beta2 | 1.1.0 | 1.6 | - |

Demo Projects
---------
You can find samples for MPP project here https://github.com/kosi-libs/Kodein-Samples

Read more
---------

Expand All @@ -116,19 +108,13 @@ Testimonies

 

<img src="https://www.collokia.com/images/collokia-logo.png" height="30" />

> At [Collokia](https://www.collokia.com/) we use Kodein in all of our backend service infrastructure and all modules in those services are loosely coupled through injection with Kodein.
> It allows us to have nice module independence, and to opt-out of injection during testing or build separate modules in support of testing.
> It is a key component and building block in our architecture.
> -- [Jayson Minard](https://github.com/apatrida)
&nbsp;

&nbsp;

<img src="https://moovel-group.com/assets/images/sign.png" height="40" />

> At [Moovel Group GmbH](https://www.moovel.com/de/en), we have successfully used the wonderful Kodein library into in [this Android app](https://play.google.com/store/apps/details?id=com.daimler.moovel.android).
> As we improved it, we found Kodein to be much more useful than Dagger2 as it simplified our code throughout.
> Kodein is in my view, much easier to understand, doesn't have that nasty ceremony, and has really nice debug messages.
Expand All @@ -137,42 +123,26 @@ Testimonies
&nbsp;

&nbsp;

<img src="https://insiteapplications.com/static/InSiteLogo.png" width="150" height="35" />

> Kodein has been instrumental in moving our entire production application to Kotlin at [InSite Applications](https://insiteapplications.com). It uses standard Kotlin idioms and features for ultimate clarity and simplicity. It was clear to us from the beginning that Kodein would be our DI solution. Our devs love it so much that they've transitioned to using it in their personal apps, both Java and Kotlin!
> -- [Eliezer Graber](https://github.com/eygraber)
&nbsp;

&nbsp;

<img src="https://cdn2.hubspot.net/hubfs/2561893/compsoft-creative-logo.jpg" height="35" />

> At [Compsoft Creative](https://www.compsoft.co.uk), Kodein is central our new Kotlin based app architecture, giving us a solid underpinning to all apps we develop and allowing a simple yet powerful way to de-couple our services with a library that is lightweight and perfect for mobile apps.
> -- [Daniel Payne](https://github.com/CompsoftCreative)
&nbsp;

&nbsp;

<img src="https://imgur.com/Ymo1qoh.jpg" height="60" />

> Kodein is used in [the android app of the OhelShem school](https://github.com/OhelShem/android).
> -- [Yoav Sternberg](https://github.com/yoavst)&nbsp;
&nbsp;

<img src="https://dental-monitoring.com/wp-content/uploads/2015/02/logo.png" height="60" />

> Kodein was created at [Dental Monitoring](https://dental-monitoring.com/) with the opinion that Dagger2 is way too verbose and complex.
> It is now used in almost all our projects: the server, the internal production software & the Android application.
> Kodein is very easy to use and set up: it allows our team to easily share code and patterns, as well as quickly bootstrapping new ideas.
> -- [Salomon Brys](https://github.com/SalomonBrys)
&nbsp;

&nbsp;

If you are using KODEIN, please [let us know](mailto:[email protected])!
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ dependencies {
api(projects.kodeinDi)
}

android {
namespace = "org.kodein.di.android"
}

kodeinUpload {
name = "Kodein-Framework-Android"
description = "Standard Kodein classes & extensions for Android"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,61 +30,61 @@ private fun closestDI(thisRef: Any?, rootContext: Context): DI {
*
* @param T The receiver type.
*/
interface DIPropertyDelegateProvider<in T> {
public interface DIPropertyDelegateProvider<in T> {
/** @suppress */
operator fun provideDelegate(thisRef: T, property: KProperty<*>?): Lazy<DI>
public operator fun provideDelegate(thisRef: T, property: KProperty<*>?): Lazy<DI>
}

private class ContextDIPropertyDelegateProvider : DIPropertyDelegateProvider<Context> {
override operator fun provideDelegate(thisRef: Context, property: KProperty<*>?) = lazy { closestDI(thisRef, thisRef) }
}

class LazyContextDIPropertyDelegateProvider(private val getContext: () -> Context) : DIPropertyDelegateProvider<Any?> {
override operator fun provideDelegate(thisRef: Any?, property: KProperty<*>?) = lazy { closestDI(thisRef, getContext()) }
public class LazyContextDIPropertyDelegateProvider(private val getContext: () -> Context) : DIPropertyDelegateProvider<Any?> {
override operator fun provideDelegate(thisRef: Any?, property: KProperty<*>?): Lazy<DI> = lazy { closestDI(thisRef, getContext()) }
}

/**
* Returns the closest DI (or the app DI, if no closest DI could be found).
*
* To be used on Android's `Context` classes, such as `Activity` or `Service`.
*/
fun closestDI(): DIPropertyDelegateProvider<Context> = ContextDIPropertyDelegateProvider()
public fun closestDI(): DIPropertyDelegateProvider<Context> = ContextDIPropertyDelegateProvider()

/**
* Returns the closest DI (or the app DI, if no closest DI could be found).
*
* @param context The Android context to use to walk up the context hierarchy.
*/
fun closestDI(context: Context): LazyContextDIPropertyDelegateProvider = LazyContextDIPropertyDelegateProvider { context }
public fun closestDI(context: Context): LazyContextDIPropertyDelegateProvider = LazyContextDIPropertyDelegateProvider { context }

/**
* Returns the closest DI (or the app DI, if no closest DI could be found).
*
* @param getContext A function that returns the Android context to use to walk up the context hierarchy.
*/
fun closestDI(getContext: () -> Context): DIPropertyDelegateProvider<Any?> = LazyContextDIPropertyDelegateProvider(getContext)
public fun closestDI(getContext: () -> Context): DIPropertyDelegateProvider<Any?> = LazyContextDIPropertyDelegateProvider(getContext)

/**
* Returns the closest DI (or the app DI, if no closest DI could be found).
*/
fun Fragment.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { activity }
public fun Fragment.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { activity }

/**
* Returns the closest DI (or the app DI, if no closest DI could be found).
*/
fun Dialog.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { context }
public fun Dialog.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { context }

/**
* Returns the closest DI (or the app DI, if no closest DI could be found).
*/
fun View.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { context }
public fun View.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { context }

/**
* Returns the closest DI (or the app DI, if no closest DI could be found).
*/
fun AbstractThreadedSyncAdapter.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { context }
public fun AbstractThreadedSyncAdapter.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { context }

/**
* Returns the closest DI (or the app DI, if no closest DI could be found).
*/
fun Loader<*>.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { context }
public fun Loader<*>.closestDI(): DIPropertyDelegateProvider<Any?> = closestDI { context }
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ import android.view.inputmethod.InputMethodManager
import android.view.textservice.TextServicesManager
import org.kodein.di.DI
import org.kodein.di.bind
import org.kodein.di.bindProvider
import org.kodein.di.bindings.Factory
import org.kodein.di.bindings.Provider
import org.kodein.di.bindings.SimpleContextTranslator
import org.kodein.type.TypeToken
import org.kodein.type.generic

val androidCoreContextTranslators = DI.Module(name = "\u2063androidCoreContextTranslators") {
public val androidCoreContextTranslators: DI.Module = DI.Module(name = "\u2063androidCoreContextTranslators") {
RegisterContextTranslator(SimpleContextTranslator<Fragment, Activity>(generic(), generic()) { it.activity })
RegisterContextTranslator(SimpleContextTranslator<Dialog, Context>(generic(), generic()) { it.context })
RegisterContextTranslator(SimpleContextTranslator<View, Context>(generic(), generic()) { it.context })
Expand All @@ -84,7 +85,7 @@ val androidCoreContextTranslators = DI.Module(name = "\u2063androidCoreContextTr
* @return An Android `DI.Module` that defines a lot of platform bindings.
*/
@SuppressLint("NewApi")
fun androidCoreModule(app: Application) = DI.Module(name = "\u2063androidModule") {
public fun androidCoreModule(app: Application): DI.Module = DI.Module(name = "\u2063androidModule") {

importOnce(androidCoreContextTranslators)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import android.os.Bundle
import org.kodein.di.*

/** @suppress */
class RetainedDIFragment : Fragment() {
public class RetainedDIFragment : Fragment() {

private var _di: DI? = null
var di: DI?
public var di: DI?
get() = _di
set(value) {
_di = value
Expand All @@ -34,7 +34,7 @@ private const val DI_RETAINED_FRAGMENT_TAG = "org.kodein.di.android.RetainedDIFr
* @property allowSilentOverride Whether this module is allowed to non-explicit overrides.
* @property init The block of configuration for this module.
*/
fun Activity.retainedDI(allowSilentOverride: Boolean = false, init: DI.MainBuilder.() -> Unit): Lazy<DI> = lazy {
public fun Activity.retainedDI(allowSilentOverride: Boolean = false, init: DI.MainBuilder.() -> Unit): Lazy<DI> = lazy {
(fragmentManager.findFragmentByTag(DI_RETAINED_FRAGMENT_TAG) as? RetainedDIFragment)?.di?.let { return@lazy it }

val di = DI(allowSilentOverride, init)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ private const val SCOPE_FRAGMENT_TAG = "org.kodein.android.ActivityRetainedScope
/**
* A scope that allows to get an activity-scoped singleton that's independent from the activity restart.
*/
open class ActivityRetainedScope private constructor(private val registryType: RegistryType) : Scope<Activity> {
public open class ActivityRetainedScope private constructor(private val registryType: RegistryType) : Scope<Activity> {

private enum class RegistryType {
Standard { override fun new() = StandardScopeRegistry() },
SingleItem { override fun new() = SingleItemScopeRegistry() };
abstract fun new(): ScopeRegistry
}

object Keys {
const val registryTypeOrdinal = "org.kodein.di.android.registryTypeOrdinal"
public object Keys {
public const val registryTypeOrdinal: String = "org.kodein.di.android.registryTypeOrdinal"
}

companion object MultiItem: ActivityRetainedScope(RegistryType.Standard)
public companion object MultiItem: ActivityRetainedScope(RegistryType.Standard)

object SingleItem: ActivityRetainedScope(RegistryType.SingleItem)
public object SingleItem: ActivityRetainedScope(RegistryType.SingleItem)

/** @suppress */
class RetainedScopeFragment: Fragment() {
val registry by lazy {
public class RetainedScopeFragment: Fragment() {
public val registry: ScopeRegistry by lazy {
val ordinal = arguments.getInt(Keys.registryTypeOrdinal)
RegistryType.values()[ordinal].new()
RegistryType.entries[ordinal].new()
}

var transactionPendingFragmentCache: MutableMap<Activity, WeakReference<RetainedScopeFragment>>? = null
public var transactionPendingFragmentCache: MutableMap<Activity, WeakReference<RetainedScopeFragment>>? = null

@Deprecated("Deprecated in Java")
override fun onAttach(context: Context?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ package org.kodein.di.android
import android.app.Activity
import org.kodein.di.*

inline fun subDI(noinline parentDI: () -> DI, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit) = DI.lazy(allowSilentOverride) {
public inline fun subDI(noinline parentDI: () -> DI, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit): LazyDI = DI.lazy(allowSilentOverride) {
extend(parentDI(), copy = copy)
init()
}

inline fun subDI(parentDI: Lazy<DI>, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit) = subDI({ parentDI.value }, allowSilentOverride, copy, init)
public inline fun subDI(parentDI: Lazy<DI>, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit): LazyDI = subDI({ parentDI.value }, allowSilentOverride, copy, init)

inline fun <T> T.subDI(parentDI: DIPropertyDelegateProvider<T>, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit) = subDI(parentDI.provideDelegate(this, null), allowSilentOverride, copy, init)
public inline fun <T> T.subDI(parentDI: DIPropertyDelegateProvider<T>, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit): LazyDI = subDI(parentDI.provideDelegate(this, null), allowSilentOverride, copy, init)

inline fun Activity.retainedSubDI(noinline parentDI: () -> DI, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit) = retainedDI(allowSilentOverride) {
public inline fun Activity.retainedSubDI(noinline parentDI: () -> DI, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit): Lazy<DI> = retainedDI(allowSilentOverride) {
extend(parentDI(), copy = copy)
init()
}

inline fun Activity.retainedSubDI(parentDI: Lazy<DI>, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit) = retainedSubDI({ parentDI.value }, allowSilentOverride, copy, init)
public inline fun Activity.retainedSubDI(parentDI: Lazy<DI>, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit): Lazy<DI> = retainedSubDI({ parentDI.value }, allowSilentOverride, copy, init)

inline fun Activity.retainedSubDI(parentDI: DIPropertyDelegateProvider<Activity>, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit) = retainedSubDI(parentDI.provideDelegate(this, null), allowSilentOverride, copy, init)
public inline fun Activity.retainedSubDI(parentDI: DIPropertyDelegateProvider<Activity>, allowSilentOverride: Boolean = false, copy: Copy = Copy.NonCached, crossinline init: DI.MainBuilder.() -> Unit): Lazy<DI> = retainedSubDI(parentDI.provideDelegate(this, null), allowSilentOverride, copy, init)
Loading

0 comments on commit d8f9e3d

Please sign in to comment.