{"id":15567013,"url":"https://github.com/daugeldauge/kinzhal","last_synced_at":"2025-05-07T19:31:43.843Z","repository":{"id":56721000,"uuid":"405349326","full_name":"daugeldauge/kinzhal","owner":"daugeldauge","description":"Compile-time dependency injection for Kotlin Multiplatform","archived":false,"fork":false,"pushed_at":"2024-06-09T19:24:55.000Z","size":292,"stargazers_count":69,"open_issues_count":6,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-22T15:17:17.613Z","etag":null,"topics":["dependency-injection","kotlin","multiplatform-kotlin-library"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daugeldauge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-11T10:28:44.000Z","updated_at":"2024-07-22T18:27:59.000Z","dependencies_parsed_at":"2023-12-05T17:40:47.488Z","dependency_job_id":"30ec39bb-1677-4940-99d4-cfcfacea9c5e","html_url":"https://github.com/daugeldauge/kinzhal","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daugeldauge%2Fkinzhal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daugeldauge%2Fkinzhal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daugeldauge%2Fkinzhal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daugeldauge%2Fkinzhal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daugeldauge","download_url":"https://codeload.github.com/daugeldauge/kinzhal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222352608,"owners_count":16970674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-injection","kotlin","multiplatform-kotlin-library"],"created_at":"2024-10-02T17:09:37.418Z","updated_at":"2024-10-31T04:03:17.490Z","avatar_url":"https://github.com/daugeldauge.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/com.daugeldauge.kinzhal/kinzhal-processor?color=blue)](https://search.maven.org/search?q=g:com.daugeldauge.kinzhal)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n\n# Kinzhal\n\nKinzhal is a Kotlin Multiplatform library for compile-time dependency injection. The goal is to emulate basic features of [Dagger](https://dagger.dev/) to achieve similar experience in Kotlin Multiplatform projects\n\nKinzhal is based on [Kotlin Symbol Processing](https://github.com/google/ksp) (KSP) — the API for lightweight compiler plugins. You'll need to set up KSP in your project to use Kinzhal\n\n## Setup\n\nAdd KSP to your plugins section:\n```kotlin\nplugins {\n    id(\"com.google.devtools.ksp\") version \"$kspVersion\"\n    kotlin(\"multiplatform\")\n    // ...\n}\n```\n\nApply Kinzhal KSP processor: \n```kotlin\ndependencies {\n    ksp(\"com.daugeldauge.kinzhal:kinzhal-processor:$kinzhalVersion\")\n}\n```\n\nAdd compile-only `kinzhal-annotations` dependency to your common source set:\n```kotlin\nkotlin {    \n    sourceSets {\n        getByName(\"commonMain\") {\n            dependencies {\n                compileOnly(\"com.daugeldauge.kinzhal:kinzhal-annotations:$kinzhalVersion\")\n                // ...\n            }\n        }\n\n        // Optional workaround for intellij-based IDEs to see generated code. This probably will be fixed someday in KSP plugin.\n        // You can replace `jvmName` with any of your target source sets. After the source set is built IDE will start to recognize generate code\n        if (System.getProperty(\"idea.sync.active\") != null) {\n            kotlin.srcDir(\"$buildDir/generated/ksp/jvmMain/kotlin\")\n        }\n    }\n}\n```\n\n\n## FAQ\n\n**What does *kinzhal* mean?**\n\nIt's a [russian word](https://en.wiktionary.org/wiki/кинжал) for dagger. Yes, *K* is not a pun\n  \n**Will this project become deprecated after Dagger releases [support for KSP and Multiplatform](https://github.com/google/dagger/issues/2349)?** \n\nProbably. But we'll see\n\n**What targets are supported?**\n\nJVM and most of Kotlin/Native targets. Kotlin/JS is not supported for now (see [#4](https://github.com/daugeldauge/kinzhal/issues/4)). Please file an issue if you don't find a target you need\n\n## Examples\n\n```kotlin\n@AppScope\n@Component(modules = [\n    NetworkModule::class,\n], dependencies = [\n    AppDependencies::class,\n])\ninterface AppComponent {\n    fun createAuthPresenter(): AuthPresenter\n}\n\ninterface AppDependencies {\n    val application: Application\n}\n\n@Scope\nannotation class AppScope\n\nclass Application\n\n@AppScope\nclass Database @Inject constructor(application: Application)\n\nclass AuthPresenter @Inject constructor(database: Database, lastFmApi: LastFmApi)\n\nclass HttpClient\n\ninterface LastFmApi\n\nclass LastFmKtorApi @Inject constructor(client: HttpClient) : LastFmApi\n\ninterface NetworkModule {\n    companion object {\n        @AppScope\n        fun provideHttpClient() = HttpClient()\n    }\n\n    fun bindLastFm(lastFmApi: LastFmKtorApi): LastFmApi\n}\n\n// somewhere in your app\nval component = KinzhalAppComponent(object : AppDependencies {\n    override val application = Application()\n})\n\nval presenter = component.createAuthPresenter()\n```\nSee more in the [source code](https://github.com/daugeldauge/kinzhal/tree/master/sample/src/commonMain/kotlin/com/daugeldauge/kinzhal/sample/graph)\n  \n## Dagger2 compatibility table\n\n| Feature    | Kinzhal support | Notes      |\n| ---------- | --------------- | -----------|\n| `@Component` | ✅ | |\n| Constructor injection | ✅ | |\n| Field injection | 🚫 | [#1](https://github.com/daugeldauge/kinzhal/issues/1) |\n| Component provision functions and properties | ✅ | |\n| `@Module` | ⚠️ | Kinzhal has modules but does not have `@Module` annotation. All classes in component module list are treated as modules. Only `object` modules with provides=functions and `interface` modules with binds-functions are allowed |\n| `@Provides` | ⚠️ | Kinzhal does not have `@Provides` annotation. All non-abstract functions in a module are considered to be provides-functions |\n| `@Binds` | ⚠️ | Kinzhal does not have `@Binds` annotation. All abstract functions in a module are considered to be binds-functions |\n| `@Scope` | ✅ | |\n| `@Qualifier` | ✅ | |\n| Component dependencies | ✅ | Dependency instances are passed to generated component's constructor instead of builder functions |\n| `@Subcomponent` | 🚫 | [#3](https://github.com/daugeldauge/kinzhal/issues/3) \u003cbr\u003e You can use component dependency to emulate behaviour of subcomponents |\n| `@Reusable` | 🚫 | |\n| `@BindsInstance` | 🚫 | You can use component dependency to bind instances |\n| Lazy/provider injections | 🚫 | [#2](https://github.com/daugeldauge/kinzhal/issues/2) |\n| `@BindsOptionalOf` | 🚫 |\n| Multibindings | 🚫 | |\n| Assisted injection | ✅ | |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaugeldauge%2Fkinzhal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaugeldauge%2Fkinzhal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaugeldauge%2Fkinzhal/lists"}