-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enable KSP2 * Remove val from function parameter in test * Use messagesWithSeverity for tests * Kotlin 2.0.21 * Update yarn.lock * Don't cache elements across rounds * Fix test failures due to logging * Fix typealiases for function injection * Fix typealiases with type parameters * KSP2 returns synthetic constructors for objects * Defer all KmpComponentCreate functions to the last round * Handle typealias to typealias * Added a KSP1 target for unit tests * Add KSP1 integration tests * Clean in between assemble and check on CI - Avoids issues until google/ksp#2231 is released * Update Kotlin to 2.1.0 * Update KSP to 2.1.0-1.0.29 * Update kotlin-compile-testing * Rename resolveToHighestTypeAlias for clarity * Remove unused property
- Loading branch information
Showing
26 changed files
with
506 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
build-logic/src/main/kotlin/kotlin-inject.multiplatform.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
integration-tests/common-test/src/test/kotlin/me/tatarka/inject/test/TypeAliasTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package me.tatarka.inject.test | ||
|
||
import assertk.assertThat | ||
import assertk.assertions.isNotNull | ||
import kotlin.test.Test | ||
|
||
class TypeAliasTest { | ||
|
||
@Test | ||
fun can_generate_for_typealias_on_typealias_function() { | ||
val component = TypeAliasesComponent::class.create() | ||
|
||
assertThat(component.typeAliasFoo()).isNotNull() | ||
} | ||
|
||
@Test | ||
fun can_generate_for_typealias_on_typealias_to_typealias_function() { | ||
val component = TypeAliasesComponent::class.create() | ||
|
||
assertThat(component.typeAliasToTypeAliasFoo()).isNotNull() | ||
} | ||
|
||
@Test | ||
fun can_generate_for_typealias_on_typealias_to_typealias_to_typealias_function() { | ||
val component = TypeAliasesComponent::class.create() | ||
|
||
assertThat(component.typeAliasToTypeAliasToTypeAliasFoo()).isNotNull() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
integration-tests/common/src/main/kotlin/me/tatarka/inject/test/TypeAlias.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package me.tatarka.inject.test | ||
|
||
import me.tatarka.inject.annotations.Component | ||
import me.tatarka.inject.annotations.Inject | ||
|
||
@Inject | ||
class TypeAliasBar | ||
|
||
typealias TypeAliasToTypeAliasBar = TypeAliasBar | ||
typealias TypeAliasToTypeAliasToTypeAliasBar = TypeAliasToTypeAliasBar | ||
|
||
@Inject | ||
fun TypeAliasFoo( | ||
bar: TypeAliasBar, | ||
typeAliasToBar: TypeAliasToTypeAliasBar, | ||
typeAliasToTypeAliasToBar: TypeAliasToTypeAliasToTypeAliasBar, | ||
) {} | ||
typealias TypeAliasFoo = () -> Unit | ||
|
||
typealias TypeAliasToTypeAliasFoo = TypeAliasFoo | ||
typealias TypeAliasToTypeAliasToTypeAliasFoo = TypeAliasToTypeAliasFoo | ||
|
||
@Component | ||
abstract class TypeAliasesComponent { | ||
abstract fun typeAliasFoo(): TypeAliasFoo | ||
abstract fun typeAliasToTypeAliasFoo(): TypeAliasToTypeAliasFoo | ||
abstract fun typeAliasToTypeAliasToTypeAliasFoo(): TypeAliasToTypeAliasToTypeAliasFoo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import com.google.devtools.ksp.KspExperimental | ||
|
||
plugins { | ||
id("kotlin-inject.multiplatform") | ||
id("kotlin-inject.detekt") | ||
id("kotlin-inject.merge-tests") | ||
id("com.google.devtools.ksp") | ||
} | ||
|
||
dependencies { | ||
addAllKspTargets(kotlin, project(":kotlin-inject-compiler:kotlin-inject-compiler-ksp")) | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
withJava() | ||
} | ||
|
||
sourceSets { | ||
commonMain { | ||
kotlin.srcDir("../common-companion/src/main/kotlin") | ||
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") | ||
dependencies { | ||
implementation(project(":kotlin-inject-runtime-kmp")) | ||
implementation(project(":integration-tests:module")) | ||
} | ||
} | ||
commonTest { | ||
kotlin.srcDir("../common-companion-test/src/test/kotlin") | ||
dependencies { | ||
implementation(libs.kotlin.test) | ||
implementation(libs.assertk) | ||
} | ||
} | ||
nativeMain { | ||
kotlin.srcDir("../common-native/src/main/kotlin") | ||
} | ||
nativeTest { | ||
kotlin.srcDir("../common-native/src/test/kotlin") | ||
} | ||
} | ||
} | ||
|
||
ksp { | ||
arg("me.tatarka.inject.generateCompanionExtensions", "true") | ||
@OptIn(KspExperimental::class) | ||
useKsp2 = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import com.google.devtools.ksp.KspExperimental | ||
|
||
plugins { | ||
id("kotlin-inject.multiplatform") | ||
id("kotlin-inject.detekt") | ||
id("kotlin-inject.merge-tests") | ||
id("com.google.devtools.ksp") | ||
} | ||
|
||
dependencies { | ||
addAllKspTargets(kotlin, project(":kotlin-inject-compiler:kotlin-inject-compiler-ksp")) | ||
kspJvmTest(project(":kotlin-inject-compiler:kotlin-inject-compiler-ksp")) | ||
} | ||
|
||
kotlin { | ||
jvm { | ||
withJava() | ||
} | ||
|
||
sourceSets { | ||
commonMain { | ||
kotlin.srcDir("../common/src/main/kotlin") | ||
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") | ||
dependencies { | ||
implementation(project(":kotlin-inject-runtime-kmp")) | ||
implementation(project(":integration-tests:module")) | ||
} | ||
} | ||
commonTest { | ||
kotlin.srcDir("../common-test/src/test/kotlin") | ||
dependencies { | ||
implementation(kotlin("test")) | ||
implementation(libs.kotlinx.coroutines) | ||
implementation(libs.assertk) | ||
} | ||
} | ||
nativeMain { | ||
kotlin.srcDir("../common-native/src/main/kotlin") | ||
} | ||
nativeTest { | ||
kotlin.srcDir("../common-native/src/test/kotlin") | ||
} | ||
jvmMain { | ||
kotlin.srcDir("../common-jvm/src/main/kotlin") | ||
dependencies { | ||
api(libs.javax.inject) | ||
} | ||
} | ||
jvmTest { | ||
kotlin.srcDir("../common-jvm/src/test/kotlin") | ||
dependencies { | ||
implementation(libs.kotlin.reflect) | ||
} | ||
} | ||
wasmJsMain { | ||
dependencies { | ||
implementation(libs.kotlinx.wasm.browser) | ||
} | ||
} | ||
} | ||
|
||
targets.all { | ||
compilations.all { | ||
compileTaskProvider.configure { | ||
compilerOptions.allWarningsAsErrors = true | ||
} | ||
} | ||
} | ||
} | ||
|
||
java { | ||
val test by sourceSets.existing { | ||
java.srcDir("../common-jvm/src/test/java") | ||
} | ||
} | ||
|
||
ksp { | ||
arg("me.tatarka.inject.enableJavaxAnnotations", "true") | ||
@OptIn(KspExperimental::class) | ||
useKsp2 = false | ||
} |
8 changes: 8 additions & 0 deletions
8
integration-tests/ksp1/src/commonTest/kotlin/me/tatarka/inject/test/runTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package me.tatarka.inject.test | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
|
||
/** | ||
* Workaround to use suspending functions in unit tests | ||
*/ | ||
expect fun runTest(block: suspend (scope: CoroutineScope) -> Unit) |
14 changes: 14 additions & 0 deletions
14
integration-tests/ksp1/src/jsTest/kotlin/me/tatarka/inject/test/runTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package me.tatarka.inject.test | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.promise | ||
|
||
/** | ||
* Workaround to use suspending functions in unit tests | ||
*/ | ||
@OptIn(DelicateCoroutinesApi::class) | ||
actual fun runTest(block: suspend (scope: CoroutineScope) -> Unit) { | ||
GlobalScope.promise { block(this) } | ||
} |
9 changes: 9 additions & 0 deletions
9
integration-tests/ksp1/src/jvmTest/kotlin/me/tatarka/inject/test/runTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package me.tatarka.inject.test | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.runBlocking | ||
|
||
/** | ||
* Workaround to use suspending functions in unit tests | ||
*/ | ||
actual fun runTest(block: suspend (scope: CoroutineScope) -> Unit) = runBlocking { block(this) } |
9 changes: 9 additions & 0 deletions
9
integration-tests/ksp1/src/nativeTest/kotlin/me/tatarka/inject/test/runTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package me.tatarka.inject.test | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.runBlocking | ||
|
||
/** | ||
* Workaround to use suspending functions in unit tests | ||
*/ | ||
actual fun runTest(block: suspend (scope: CoroutineScope) -> Unit) = runBlocking { block(this) } |
14 changes: 14 additions & 0 deletions
14
integration-tests/ksp1/src/wasmJsTest/kotlin/me/tatarka/inject/test/runTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package me.tatarka.inject.test | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.promise | ||
|
||
/** | ||
* Workaround to use suspending functions in unit tests | ||
*/ | ||
@OptIn(DelicateCoroutinesApi::class) | ||
actual fun runTest(block: suspend (scope: CoroutineScope) -> Unit) { | ||
GlobalScope.promise { block(this) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.