Skip to content

Commit 9a91124

Browse files
committed
prepare release 0.7.0
1 parent 068af05 commit 9a91124

File tree

4 files changed

+65
-25
lines changed

4 files changed

+65
-25
lines changed

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [0.7.0] 2024-06-12
99

1010
### Changed
1111
- `@Scope` annotations now take arguments into account. This means for example, if you have
@@ -43,10 +43,33 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4343
}
4444
```
4545
This behaves the same as `javax.inject.Qualifier` does when you have `me.tatarka.inject.enableJavaxAnnotations=true`.
46+
- Added a new `@KmpComponentCreate` annotation for nicer multiplatform support. This allows you to create component
47+
instances from common code when generating platform-specific outputs.
48+
```kotlin
49+
// src/commonMain
50+
@Component
51+
abstract class MyKmpComponent
52+
53+
@KmpComponentCreate
54+
expect fun createKmp(): MyKmpComponent
55+
```
56+
see the new [multiplatform docs](docs/multiplatform.md) for more details.
57+
- You can now use an `@Inject` annotation on an inner class provided the outer class can be provided.
58+
```kotlin
59+
@Inject class Outer { @Inject inner class Inner }
60+
61+
@Component abstract class MyComponent { abstract val inner: Outer.Inner }
62+
```
4663

4764
### Removed
4865
- The KAPT backend is removed, please migrate to KSP if you haven't already.
4966
67+
### Fixed
68+
- Fixed cases of invalid code generation (#321, #337, #313).
69+
- Fixed an exception thrown on KSP2 when running multiple rounds (google/ksp#1854).
70+
- Fixed various issues with handling method overrides in components (#309, #375)
71+
- Allow scope annotations on both an interface and component implementation if they are the same scope (#320).
72+
5073
## [0.6.3] 2023-09-02
5174
5275
### Fixed

README.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,8 @@ repositories {
6464
}
6565
6666
dependencies {
67-
ksp("me.tatarka.inject:kotlin-inject-compiler-ksp:0.6.3")
68-
implementation("me.tatarka.inject:kotlin-inject-runtime:0.6.3")
69-
}
70-
```
71-
72-
### or with KAPT (deprecated)
73-
74-
```groovy
75-
plugins {
76-
id("org.jetbrains.kotlin.jvm") version "1.9.0"
77-
id("org.jetbrains.kotlin.kapt") version "1.9.0"
78-
}
79-
80-
dependencies {
81-
kapt("me.tatarka.inject:kotlin-inject-compiler-kapt:0.6.3")
82-
implementation("me.tatarka.inject:kotlin-inject-runtime:0.6.3")
67+
ksp("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
68+
implementation("me.tatarka.inject:kotlin-inject-runtime:0.7.0")
8369
}
8470
```
8571

@@ -187,10 +173,41 @@ val parent = ParentComponent::class.create()
187173
val child = ChildComponent::class.create(parent)
188174
```
189175

176+
### Qualifiers
177+
178+
If you have multiple instances of the same type you want to differentiate, you can use a `@Qualifier`. They will be
179+
treated as separate types for the purposes of injection. They can be placed either on the variable or the type.
180+
181+
```kotlin
182+
@Qualifier
183+
@Target(
184+
AnnotationTarget.PROPERTY_GETTER,
185+
AnnotationTarget.FUNCTION,
186+
AnnotationTarget.VALUE_PARAMETER,
187+
AnnotationTarget.TYPE
188+
)
189+
annotation class Named(val value: String)
190+
191+
@Component
192+
abstract class MyComponent {
193+
@Provides
194+
fun dep1(): @Named("one") Dep = Dep("one")
195+
196+
@Provides
197+
fun dep2(): @Named("two") Dep = Dep("two")
198+
199+
@Provides
200+
fun provides(@Named("one") dep1: Dep, @Named("two") dep2: Dep): Thing = Thing(dep1, dep2)
201+
}
202+
203+
@Inject
204+
class InjectedClass(@Named("one") dep1: Dep, @Named("two") dep2: Dep)
205+
```
206+
190207
### Type Alias Support
191208

192-
If you have multiple instances of the same type you want to differentiate, you can use type aliases. They will be
193-
treated as separate types for the purposes of injection.
209+
Alternatively different typealises will be treated as different types. (Note: this is going away in a future release, so
210+
consider using a `@Qualifier` annotation instead. There will be a migration path.)
194211

195212
```kotlin
196213
typealias Dep1 = Dep

docs/multiplatform.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Add the runtime dependency in commonMain
4040
sourceSets {
4141
commonMain {
4242
dependencies {
43-
implementation("me.tatarka.inject:kotlin-inject-runtime-kmp:0.7.0-SNAPSHOT")
43+
implementation("me.tatarka.inject:kotlin-inject-runtime-kmp:0.7.0")
4444
}
4545
}
4646
}
@@ -67,10 +67,10 @@ dependencies {
6767
kspCommonMainMetadata(libs.kotlinInject)
6868

6969
// 2. Configure code generation into each KMP target source set
70-
kspAndroid("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0-SNAPSHOT")
71-
kspIosX64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0-SNAPSHOT")
72-
kspIosArm64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0-SNAPSHOT")
73-
kspIosSimulatorArm64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0-SNAPSHOT")
70+
kspAndroid("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
71+
kspIosX64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
72+
kspIosArm64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
73+
kspIosSimulatorArm64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
7474
}
7575
```
7676

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlin-inject = "0.7.0-SNAPSHOT"
2+
kotlin-inject = "0.7.0"
33
kotlin = "1.9.24"
44
ksp = "1.9.24-1.0.20"
55
kotlinpoet = "1.16.0"

0 commit comments

Comments
 (0)