Skip to content

Commit

Permalink
prepare release 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
evant committed Jun 12, 2024
1 parent 068af05 commit 9a91124
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 25 deletions.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.7.0] 2024-06-12

### Changed
- `@Scope` annotations now take arguments into account. This means for example, if you have
Expand Down Expand Up @@ -43,10 +43,33 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
}
```
This behaves the same as `javax.inject.Qualifier` does when you have `me.tatarka.inject.enableJavaxAnnotations=true`.
- Added a new `@KmpComponentCreate` annotation for nicer multiplatform support. This allows you to create component
instances from common code when generating platform-specific outputs.
```kotlin
// src/commonMain
@Component
abstract class MyKmpComponent

@KmpComponentCreate
expect fun createKmp(): MyKmpComponent
```
see the new [multiplatform docs](docs/multiplatform.md) for more details.
- You can now use an `@Inject` annotation on an inner class provided the outer class can be provided.
```kotlin
@Inject class Outer { @Inject inner class Inner }

@Component abstract class MyComponent { abstract val inner: Outer.Inner }
```

### Removed
- The KAPT backend is removed, please migrate to KSP if you haven't already.
### Fixed
- Fixed cases of invalid code generation (#321, #337, #313).
- Fixed an exception thrown on KSP2 when running multiple rounds (google/ksp#1854).
- Fixed various issues with handling method overrides in components (#309, #375)
- Allow scope annotations on both an interface and component implementation if they are the same scope (#320).
## [0.6.3] 2023-09-02
### Fixed
Expand Down
53 changes: 35 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,8 @@ repositories {
}
dependencies {
ksp("me.tatarka.inject:kotlin-inject-compiler-ksp:0.6.3")
implementation("me.tatarka.inject:kotlin-inject-runtime:0.6.3")
}
```

### or with KAPT (deprecated)

```groovy
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.0"
id("org.jetbrains.kotlin.kapt") version "1.9.0"
}
dependencies {
kapt("me.tatarka.inject:kotlin-inject-compiler-kapt:0.6.3")
implementation("me.tatarka.inject:kotlin-inject-runtime:0.6.3")
ksp("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
implementation("me.tatarka.inject:kotlin-inject-runtime:0.7.0")
}
```

Expand Down Expand Up @@ -187,10 +173,41 @@ val parent = ParentComponent::class.create()
val child = ChildComponent::class.create(parent)
```

### Qualifiers

If you have multiple instances of the same type you want to differentiate, you can use a `@Qualifier`. They will be
treated as separate types for the purposes of injection. They can be placed either on the variable or the type.

```kotlin
@Qualifier
@Target(
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.FUNCTION,
AnnotationTarget.VALUE_PARAMETER,
AnnotationTarget.TYPE
)
annotation class Named(val value: String)

@Component
abstract class MyComponent {
@Provides
fun dep1(): @Named("one") Dep = Dep("one")

@Provides
fun dep2(): @Named("two") Dep = Dep("two")

@Provides
fun provides(@Named("one") dep1: Dep, @Named("two") dep2: Dep): Thing = Thing(dep1, dep2)
}

@Inject
class InjectedClass(@Named("one") dep1: Dep, @Named("two") dep2: Dep)
```

### Type Alias Support

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

```kotlin
typealias Dep1 = Dep
Expand Down
10 changes: 5 additions & 5 deletions docs/multiplatform.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Add the runtime dependency in commonMain
sourceSets {
commonMain {
dependencies {
implementation("me.tatarka.inject:kotlin-inject-runtime-kmp:0.7.0-SNAPSHOT")
implementation("me.tatarka.inject:kotlin-inject-runtime-kmp:0.7.0")
}
}
}
Expand All @@ -67,10 +67,10 @@ dependencies {
kspCommonMainMetadata(libs.kotlinInject)

// 2. Configure code generation into each KMP target source set
kspAndroid("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0-SNAPSHOT")
kspIosX64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0-SNAPSHOT")
kspIosArm64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0-SNAPSHOT")
kspIosSimulatorArm64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0-SNAPSHOT")
kspAndroid("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
kspIosX64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
kspIosArm64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
kspIosSimulatorArm64("me.tatarka.inject:kotlin-inject-compiler-ksp:0.7.0")
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin-inject = "0.7.0-SNAPSHOT"
kotlin-inject = "0.7.0"
kotlin = "1.9.24"
ksp = "1.9.24-1.0.20"
kotlinpoet = "1.16.0"
Expand Down

0 comments on commit 9a91124

Please sign in to comment.