diff --git a/README.md b/README.md index dd087b8..023c797 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build](https://img.shields.io/github/actions/workflow/status/harrytmthy/stitch/ci.yml?branch=main&label=build&logo=githubactions&logoColor=white&style=flat-square)](https://github.com/harrytmthy/stitch/actions) [![License](https://img.shields.io/github/license/harrytmthy/stitch?label=license&color=blue&style=flat-square)](https://github.com/harrytmthy/stitch/blob/main/LICENSE) +[![Release](https://img.shields.io/github/v/release/harrytmthy/stitch?include_prereleases&label=release&color=orange&style=flat-square)](https://github.com/harrytmthy/stitch/releases) A Kotlin Multiplatform dependency injection library with a precompiled path and a runtime registration path, designed to replace the Dagger + Koin split with one consistent model. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6cb9845..4ff4595 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,7 @@ kotlinpoet = "2.3.0" kotlinAtomicfu = "0.32.1" ksp = "2.3.6" mavenPublishPlugin = "0.32.0" +stitch = "1.0.0-rc01" [libraries] androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppcompat" } @@ -36,6 +37,9 @@ kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.re kotlinpoet = { group = "com.squareup", name = "kotlinpoet", version.ref = "kotlinpoet" } kotlinpoet-ksp = { group = "com.squareup", name = "kotlinpoet-ksp", version.ref = "kotlinpoet" } ksp-api = { group = "com.google.devtools.ksp", name = "symbol-processing-api", version.ref = "ksp" } +stitch = { group = "io.github.harrytmthy", name = "stitch", version.ref = "stitch" } +stitch-annotations = { group = "io.github.harrytmthy", name = "stitch-annotations", version.ref = "stitch" } +stitch-ksp = { group = "io.github.harrytmthy", name = "stitch-ksp", version.ref = "stitch" } # Dependencies of build-logic android-gradle = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } diff --git a/samples/app/build.gradle.kts b/samples/app/build.gradle.kts index 3ccc0a9..08efe0a 100644 --- a/samples/app/build.gradle.kts +++ b/samples/app/build.gradle.kts @@ -275,10 +275,10 @@ dependencies { implementation(libs.androidx.core.ktx) // Stitch flavor only - "stitchImplementation"(project(":stitch")) - "stitchCompileOnly"(project(":stitch-annotations")) + "stitchImplementation"(libs.stitch) + "stitchCompileOnly"(libs.stitch.annotations) "stitchCompileOnly"(libs.javax.inject) - "kspStitch"(project(":stitch-ksp")) + "kspStitch"(libs.stitch.ksp) // Dagger flavor only "daggerImplementation"(libs.dagger) diff --git a/samples/core/build.gradle.kts b/samples/core/build.gradle.kts index 50e6945..f9d90b9 100644 --- a/samples/core/build.gradle.kts +++ b/samples/core/build.gradle.kts @@ -36,9 +36,9 @@ android { dependencies { "withStitchCompileOnly"(libs.javax.inject) - "withStitchCompileOnly"(project(":stitch-annotations")) - "withStitchImplementation"(project(":stitch")) - "kspWithStitch"(project(":stitch-ksp")) + "withStitchCompileOnly"(libs.stitch.annotations) + "withStitchImplementation"(libs.stitch) + "kspWithStitch"(libs.stitch.ksp) "withDaggerCompileOnly"(libs.javax.inject) "withDaggerImplementation"(libs.dagger) "kspWithDagger"(libs.dagger.compiler) diff --git a/samples/feature/home/build.gradle.kts b/samples/feature/home/build.gradle.kts index 9b94d65..8348f9d 100644 --- a/samples/feature/home/build.gradle.kts +++ b/samples/feature/home/build.gradle.kts @@ -38,9 +38,9 @@ dependencies { implementation(project(":core")) implementation(libs.androidx.appcompat) "withStitchCompileOnly"(libs.javax.inject) - "withStitchCompileOnly"(project(":stitch-annotations")) - "withStitchImplementation"(project(":stitch")) - "kspWithStitch"(project(":stitch-ksp")) + "withStitchCompileOnly"(libs.stitch.annotations) + "withStitchImplementation"(libs.stitch) + "kspWithStitch"(libs.stitch.ksp) "withDaggerCompileOnly"(libs.javax.inject) "withDaggerImplementation"(libs.dagger) "kspWithDagger"(libs.dagger.compiler) diff --git a/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/Named.kt b/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/Named.kt index 3185f01..a573dcc 100644 --- a/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/Named.kt +++ b/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/Named.kt @@ -17,7 +17,7 @@ package com.harrytmthy.stitch.annotations /** - * A string-based qualifier annotation for the DI path. + * A string-based qualifier annotation for the precompiled path. * * Use this to differentiate between multiple bindings of the same type. * diff --git a/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/Scope.kt b/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/Scope.kt index 9d8e90b..951c8f9 100644 --- a/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/Scope.kt +++ b/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/Scope.kt @@ -17,7 +17,7 @@ package com.harrytmthy.stitch.annotations /** - * Meta-annotation that identifies a scope annotation for the DI path. + * Meta-annotation that identifies a scope annotation for the precompiled path. * * Scope annotations control the lifecycle and sharing of dependencies within a specific scope * (e.g. Activity scope, Fragment scope). Combine with [DependsOn] to form a unidirectional diff --git a/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/StitchRoot.kt b/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/StitchRoot.kt index aa57354..4caaf2c 100644 --- a/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/StitchRoot.kt +++ b/stitch-annotations/src/commonMain/kotlin/com/harrytmthy/stitch/annotations/StitchRoot.kt @@ -17,7 +17,7 @@ package com.harrytmthy.stitch.annotations /** - * Marks a class as the root aggregation point for Stitch's DI code generation. + * Marks a class as the root aggregation point for the precompiled path's code generation. * * The KSP processor collects all contributed bindings and scopes across modules and * generates the final dependency graph at this class's module. Typically placed on diff --git a/stitch-ksp/src/main/kotlin/com/harrytmthy/stitch/ksp/StitchSymbolProcessor.kt b/stitch-ksp/src/main/kotlin/com/harrytmthy/stitch/ksp/StitchSymbolProcessor.kt index 519e567..9c2a66f 100644 --- a/stitch-ksp/src/main/kotlin/com/harrytmthy/stitch/ksp/StitchSymbolProcessor.kt +++ b/stitch-ksp/src/main/kotlin/com/harrytmthy/stitch/ksp/StitchSymbolProcessor.kt @@ -29,10 +29,10 @@ import com.harrytmthy.stitch.ksp.utils.StitchErrorLogger import java.security.MessageDigest /** - * KSP symbol processor for Stitch dependency injection code generation. + * KSP symbol processor for Stitch precompiled graph generation. * - * This processor scans for @Module classes, @Provides methods, and @Inject constructors/fields, - * then generates DI component and injector objects for compile-time dependency resolution. + * This processor scans `@Provides`, constructor injection, field injection, and scope declarations, + * then generates injectors and graphs for Stitch's precompiled path. */ class StitchSymbolProcessor(private val environment: SymbolProcessorEnvironment) : SymbolProcessor { diff --git a/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/DclHolder.kt b/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/DclHolder.kt index 2df65d6..abedd51 100644 --- a/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/DclHolder.kt +++ b/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/DclHolder.kt @@ -19,8 +19,8 @@ package com.harrytmthy.stitch.api import kotlinx.atomicfu.atomic /** - * A thread-safe holder for double-checked locking, used by generated DI graphs - * to lazily initialize bindings. + * A thread-safe holder for double-checked locking, used by generated precompiled graphs + * to lazily initialize scoped and singleton bindings. * * Check [reference] against [Uninitialized] to determine whether the value has been set, * using [lock] for synchronization. diff --git a/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/Injector.kt b/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/Injector.kt index 39e0d9f..ce79338 100644 --- a/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/Injector.kt +++ b/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/Injector.kt @@ -19,7 +19,7 @@ package com.harrytmthy.stitch.api import kotlin.reflect.KClass /** - * Core interface for Stitch's DI path. Generated scope graphs implement this interface. + * Core interface for Stitch's precompiled path. Generated graphs implement this interface. * * Each [Injector] represents a single scope in the dependency graph and can create child * injectors for downstream scopes: diff --git a/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/Stitch.kt b/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/Stitch.kt index 7a15bc9..45941f6 100644 --- a/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/Stitch.kt +++ b/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/Stitch.kt @@ -25,7 +25,7 @@ import com.harrytmthy.stitch.internal.Registry import kotlin.reflect.KClass /** - * Main entry point for Stitch's service locator (SL) path. + * Main entry point for Stitch's runtime registration path. * * Use [register] and [unregister] to manage modules at runtime, and [get] or [inject] to * resolve dependencies. @@ -41,7 +41,7 @@ import kotlin.reflect.KClass * val logger: Logger = Stitch.get() * ``` * - * For the DI path, see [StitchInjector]. + * For the precompiled path, see [StitchInjector]. */ object Stitch { diff --git a/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/StitchInjector.kt b/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/StitchInjector.kt index a6a0a42..858333b 100644 --- a/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/StitchInjector.kt +++ b/stitch/src/commonMain/kotlin/com/harrytmthy/stitch/api/StitchInjector.kt @@ -22,7 +22,7 @@ import com.harrytmthy.stitch.internal.ConcurrentHashMap import kotlinx.atomicfu.atomic /** - * Global registry for Stitch's DI path. Manages the singleton graph and caches + * Global registry for Stitch's precompiled path. Manages the singleton graph and caches * injector instances across scopes. * * Initialize with the generated singleton graph on application startup: @@ -48,7 +48,7 @@ object StitchInjector { private val nextId = atomic(1) /** - * Initializes the DI graph with the generated [singletonGraph]. + * Initializes the precompiled graph with the generated [singletonGraph]. * * This must be called before any [getSingletonGraph] or scope creation. */