Repository: evant/kotlin-inject
Pull request #72 (2020-09-25 20:10:40)

Update ksp

evant: Blocked until https://github.com/tschuchortdev/kotlin-compile-testing/pull/67 is merged

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 655ca28..af1f71e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,5 +5,20 @@ 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).
 
 
+## [0.2.0] - 2020-09-28
+
+### Changed
+- [Migrate](https://github.com/google/ksp/blob/master/old-ksp-release.md) ksp 
+- Improve kapt error messaging
+- Build performance improvements
+  
+### Added
+- Allow annotating interfaces with `@Component`
+- Support `javax.inject.Qualifer`
+
+### Fixed
+- Fixed companion generation (`me.tatarka.inject.generateCompanionExtensions=true`) for ksp
+- Throw error when parent component is missing val instead of generating incorrect code.
+
 ## [0.1.0] - 2020-09-17
 - Initial Release
diff --git a/README.md b/README.md
index 2d6073e..e073883 100644
--- a/README.md
+++ b/README.md
@@ -32,14 +32,14 @@ plugins {
 }
 
 dependencies {
-    kapt "me.tatarka.inject:kotlin-inject-compiler-kapt:0.1.0"
-    implementation "me.tatarka.inject:kotlin-inject-runtime:0.1.0"
+    kapt "me.tatarka.inject:kotlin-inject-compiler-kapt:0.2.0"
+    implementation "me.tatarka.inject:kotlin-inject-runtime:0.2.0"
 }
 ```
 
 ### Experimental KSP Support 
 
-You can use [ksp](https://github.com/android/kotlin/tree/ksp/libraries/tools/kotlin-symbol-processing-api) instead of 
+You can use [ksp](https://github.com/google/ksp) instead of 
 kapt.
 
 `settings.gradle`
@@ -48,10 +48,8 @@ pluginManagement {
     resolutionStrategy {
         eachPlugin {
             switch (requested.id.id) {
-                case "kotlin-ksp":
-                case "org.jetbrains.kotlin.kotlin-ksp":
-                case "org.jetbrains.kotlin.ksp":
-                    useModule("org.jetbrains.kotlin:kotlin-ksp:${requested.version}")
+                case "symbol-processing":
+                    useModule("com.google.devtools.ksp:symbol-processing:${requested.version}")
             }
         }
     }
@@ -66,8 +64,8 @@ pluginManagement {
 `build.gradle`
 ```groovy
 plugins {
-    id 'org.jetbrains.kotlin.jvm' version '1.4.0'
-    id 'org.jetbrains.kotlin.ksp' version '1.4.0-dev-experimental-20200914'
+    id 'org.jetbrains.kotlin.jvm' version '1.4.10'
+    id 'symbol-processing' version '1.4.10-dev-experimental-20200924'
 }
 
 repositories {
@@ -76,8 +74,8 @@ repositories {
 }
 
 dependencies {
-    ksp "me.tatarka.inject:kotlin-inject-compiler-ksp:0.1.0"
-    implementation "me.tatarka.inject:kotlin-inject-runtime:0.1.0"
+    ksp "me.tatarka.inject:kotlin-inject-compiler-ksp:0.2.0"
+    implementation "me.tatarka.inject:kotlin-inject-runtime:0.2.0"
 }
 ```
 
@@ -356,7 +354,7 @@ You can provide some additional options to the processor.
 
 - `me.tatarka.inject.enableJavaxAnnotations=true`
 
-  `@javax.inject.Inject` and `@javax.inject.Scope` can be used in addition to the provided annotations. This can be useful
+  `@javax.inject.*` annotations can be used in in addition to the provided annotations. This can be useful
   if you are migrating existing code or want to be abstracted from the injection lib you are using on the jvm.
 
 - `me.tatarka.inject.generateCompanionExtensions=true`
diff --git a/build.gradle b/build.gradle
index d6bd37a..034e88f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
 plugins {
     id 'org.jetbrains.kotlin.jvm' version '1.4.0' apply false
+    id 'symbol-processing' version "1.4.10-dev-experimental-20200924" apply false
 }
 
 subprojects {
diff --git a/kotlin-inject-compiler-ksp/build.gradle b/kotlin-inject-compiler-ksp/build.gradle
index 8faeddb..b0edd0b 100644
--- a/kotlin-inject-compiler-ksp/build.gradle
+++ b/kotlin-inject-compiler-ksp/build.gradle
@@ -6,7 +6,7 @@ dependencies {
     implementation project(':kotlin-inject-runtime')
     implementation project(':kotlin-inject-compiler-core')
     implementation "org.jetbrains.kotlin:kotlin-stdlib"
-    implementation 'org.jetbrains.kotlin:kotlin-symbol-processing-api:1.4.0-dev-experimental-20200914'
+    implementation 'com.google.devtools.ksp:symbol-processing-api:1.4.10-dev-experimental-20200924'
 }
 
 sourceCompatibility = 1.8
diff --git a/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt b/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt
index 20aa2ba..6325417 100644
--- a/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt
+++ b/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/InjectProcessor.kt
@@ -6,11 +6,11 @@ import me.tatarka.inject.compiler.FailedToGenerateException
 import me.tatarka.inject.compiler.InjectGenerator
 import me.tatarka.inject.compiler.Options
 import me.tatarka.inject.compiler.Profiler
-import org.jetbrains.kotlin.ksp.processing.CodeGenerator
-import org.jetbrains.kotlin.ksp.processing.KSPLogger
-import org.jetbrains.kotlin.ksp.processing.Resolver
-import org.jetbrains.kotlin.ksp.processing.SymbolProcessor
-import org.jetbrains.kotlin.ksp.symbol.KSClassDeclaration
+import com.google.devtools.ksp.processing.CodeGenerator
+import com.google.devtools.ksp.processing.KSPLogger
+import com.google.devtools.ksp.processing.Resolver
+import com.google.devtools.ksp.processing.SymbolProcessor
+import com.google.devtools.ksp.symbol.KSClassDeclaration
 
 class InjectProcessor(private val profiler: Profiler? = null) : SymbolProcessor, KSAstProvider {
 
diff --git a/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/KSAst.kt b/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/KSAst.kt
index f1b70fa..0abb986 100644
--- a/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/KSAst.kt
+++ b/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/KSAst.kt
@@ -18,27 +18,27 @@ import me.tatarka.inject.compiler.AstProperty
 import me.tatarka.inject.compiler.AstProvider
 import me.tatarka.inject.compiler.AstType
 import me.tatarka.inject.compiler.Messenger
-import org.jetbrains.kotlin.ksp.findActualType
-import org.jetbrains.kotlin.ksp.getDeclaredFunctions
-import org.jetbrains.kotlin.ksp.getDeclaredProperties
-import org.jetbrains.kotlin.ksp.isAbstract
-import org.jetbrains.kotlin.ksp.isPrivate
-import org.jetbrains.kotlin.ksp.processing.KSPLogger
-import org.jetbrains.kotlin.ksp.processing.Resolver
-import org.jetbrains.kotlin.ksp.symbol.AnnotationUseSiteTarget
-import org.jetbrains.kotlin.ksp.symbol.ClassKind
-import org.jetbrains.kotlin.ksp.symbol.FileLocation
-import org.jetbrains.kotlin.ksp.symbol.KSAnnotated
-import org.jetbrains.kotlin.ksp.symbol.KSAnnotation
-import org.jetbrains.kotlin.ksp.symbol.KSClassDeclaration
-import org.jetbrains.kotlin.ksp.symbol.KSDeclaration
-import org.jetbrains.kotlin.ksp.symbol.KSFunctionDeclaration
-import org.jetbrains.kotlin.ksp.symbol.KSPropertyDeclaration
-import org.jetbrains.kotlin.ksp.symbol.KSType
-import org.jetbrains.kotlin.ksp.symbol.KSTypeAlias
-import org.jetbrains.kotlin.ksp.symbol.KSTypeReference
-import org.jetbrains.kotlin.ksp.symbol.KSVariableParameter
-import org.jetbrains.kotlin.ksp.symbol.Variance
+import com.google.devtools.ksp.findActualType
+import com.google.devtools.ksp.getDeclaredFunctions
+import com.google.devtools.ksp.getDeclaredProperties
+import com.google.devtools.ksp.isAbstract
+import com.google.devtools.ksp.isPrivate
+import com.google.devtools.ksp.processing.KSPLogger
+import com.google.devtools.ksp.processing.Resolver
+import com.google.devtools.ksp.symbol.AnnotationUseSiteTarget
+import com.google.devtools.ksp.symbol.ClassKind
+import com.google.devtools.ksp.symbol.FileLocation
+import com.google.devtools.ksp.symbol.KSAnnotated
+import com.google.devtools.ksp.symbol.KSAnnotation
+import com.google.devtools.ksp.symbol.KSClassDeclaration
+import com.google.devtools.ksp.symbol.KSDeclaration
+import com.google.devtools.ksp.symbol.KSFunctionDeclaration
+import com.google.devtools.ksp.symbol.KSPropertyDeclaration
+import com.google.devtools.ksp.symbol.KSType
+import com.google.devtools.ksp.symbol.KSTypeAlias
+import com.google.devtools.ksp.symbol.KSTypeReference
+import com.google.devtools.ksp.symbol.KSVariableParameter
+import com.google.devtools.ksp.symbol.Variance
 import kotlin.reflect.KClass
 
 interface KSAstProvider : AstProvider {
diff --git a/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/Util.kt b/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/Util.kt
index f4d17a2..f3dfef0 100644
--- a/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/Util.kt
+++ b/kotlin-inject-compiler-ksp/src/main/kotlin/me/tatarka/inject/compiler/ksp/Util.kt
@@ -9,22 +9,22 @@ import me.tatarka.inject.compiler.HashCollector
 import me.tatarka.inject.compiler.collectHash
 import me.tatarka.inject.compiler.eqv
 import me.tatarka.inject.compiler.eqvItr
-import org.jetbrains.kotlin.ksp.isAbstract
-import org.jetbrains.kotlin.ksp.symbol.AnnotationUseSiteTarget
-import org.jetbrains.kotlin.ksp.symbol.KSAnnotated
-import org.jetbrains.kotlin.ksp.symbol.KSAnnotation
-import org.jetbrains.kotlin.ksp.symbol.KSClassDeclaration
-import org.jetbrains.kotlin.ksp.symbol.KSDeclaration
-import org.jetbrains.kotlin.ksp.symbol.KSFunctionDeclaration
-import org.jetbrains.kotlin.ksp.symbol.KSNode
-import org.jetbrains.kotlin.ksp.symbol.KSPropertyDeclaration
-import org.jetbrains.kotlin.ksp.symbol.KSType
-import org.jetbrains.kotlin.ksp.symbol.KSTypeAlias
-import org.jetbrains.kotlin.ksp.symbol.KSTypeParameter
-import org.jetbrains.kotlin.ksp.symbol.KSTypeReference
-import org.jetbrains.kotlin.ksp.symbol.Nullability
-import org.jetbrains.kotlin.ksp.symbol.Variance
-import org.jetbrains.kotlin.ksp.visitor.KSDefaultVisitor
+import com.google.devtools.ksp.isAbstract
+import com.google.devtools.ksp.symbol.AnnotationUseSiteTarget
+import com.google.devtools.ksp.symbol.KSAnnotated
+import com.google.devtools.ksp.symbol.KSAnnotation
+import com.google.devtools.ksp.symbol.KSClassDeclaration
+import com.google.devtools.ksp.symbol.KSDeclaration
+import com.google.devtools.ksp.symbol.KSFunctionDeclaration
+import com.google.devtools.ksp.symbol.KSNode
+import com.google.devtools.ksp.symbol.KSPropertyDeclaration
+import com.google.devtools.ksp.symbol.KSType
+import com.google.devtools.ksp.symbol.KSTypeAlias
+import com.google.devtools.ksp.symbol.KSTypeParameter
+import com.google.devtools.ksp.symbol.KSTypeReference
+import com.google.devtools.ksp.symbol.Nullability
+import com.google.devtools.ksp.symbol.Variance
+import com.google.devtools.ksp.visitor.KSDefaultVisitor
 
 fun KSAnnotated.annotationAnnotatedWith(
     className: String,
diff --git a/kotlin-inject-compiler-ksp/src/main/resources/META-INF/services/org.jetbrains.kotlin.ksp.processing.SymbolProcessor b/kotlin-inject-compiler-ksp/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessor
similarity index 100%
rename from kotlin-inject-compiler-ksp/src/main/resources/META-INF/services/org.jetbrains.kotlin.ksp.processing.SymbolProcessor
rename to kotlin-inject-compiler-ksp/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessor
diff --git a/publish.gradle b/publish.gradle
index 43926ae..6fb871a 100644
--- a/publish.gradle
+++ b/publish.gradle
@@ -2,7 +2,7 @@ apply plugin: 'signing'
 apply plugin: 'maven-publish'
 
 group = 'me.tatarka.inject'
-version = '0.1.1-SNAPSHOT'
+version = '0.2.0'
 
 task sourcesJar(type: Jar) {
     from sourceSets.main.allJava
diff --git a/settings.gradle b/settings.gradle
index f540df0..3ad3c2d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -7,10 +7,8 @@ pluginManagement {
     resolutionStrategy {
         eachPlugin {
             switch (requested.id.id) {
-                case "kotlin-ksp":
-                case "org.jetbrains.kotlin.kotlin-ksp":
-                case "org.jetbrains.kotlin.ksp":
-                    useModule("org.jetbrains.kotlin:kotlin-ksp:${requested.version}")
+                case "symbol-processing":
+                    useModule("com.google.devtools.ksp:symbol-processing:${requested.version}")
             }
         }
     }


Test patch:
diff --git a/compiler-tests/build.gradle b/compiler-tests/build.gradle
index b065db4..95d4dfb 100644
--- a/compiler-tests/build.gradle
+++ b/compiler-tests/build.gradle
@@ -9,18 +9,9 @@ dependencies {
     implementation project(':kotlin-inject-compiler-kapt')
     implementation project(':kotlin-inject-compiler-ksp')
 
-    implementation 'com.github.tschuchortdev:kotlin-compile-testing-ksp:1.2.10'
+    implementation 'com.github.tschuchortdev:kotlin-compile-testing-ksp:1.3.1'
     implementation 'org.jetbrains.kotlin:kotlin-compiler-embeddable:1.4.0'
-    implementation('org.jetbrains.kotlin:kotlin-ksp') {
-        version {
-            strictly '1.4.0-dev-experimental-20200914'
-        }
-    }
-    implementation('org.jetbrains.kotlin:kotlin-symbol-processing-api') {
-        version {
-            strictly '1.4.0-dev-experimental-20200914'
-        }
-    }
+    implementation 'com.google.devtools.ksp:symbol-processing-api:1.4.10-dev-experimental-20200924'
 
     testImplementation "org.jetbrains.kotlin:kotlin-test"
     testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
diff --git a/compiler-tests/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt b/compiler-tests/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt
index 321dd43..6d79696 100644
--- a/compiler-tests/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt
+++ b/compiler-tests/src/main/kotlin/me/tatarka/inject/ProjectCompiler.kt
@@ -47,8 +47,7 @@ class ProjectCompiler(
                 }
                 Target.ksp -> {
                     options?.let {
-                        //TODO: wait on https://github.com/tschuchortdev/kotlin-compile-testing/pull/66
-//                        kspArgs.putAll(it.toMap())
+                        kspArgs.putAll(it.toMap())
                     }
                     symbolProcessors = listOf(InjectProcessor(profiler))
                 }
diff --git a/compiler-tests/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt b/compiler-tests/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt
index a34873c..5c18a0e 100644
--- a/compiler-tests/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt
+++ b/compiler-tests/src/test/kotlin/me/tatarka/inject/test/FailureTest.kt
@@ -281,7 +281,6 @@ class FailureTest(val target: Target) {
     }
 
     @Test
-    @Ignore("waiting on https://github.com/tschuchortdev/kotlin-compile-testing/pull/66")
     fun fails_if_companion_option_is_enabled_but_companion_is_missing() {
         assertThat {
             projectCompiler.source(
diff --git a/integration-tests/ksp-companion/build.gradle b/integration-tests/ksp-companion/build.gradle
index 612f588..c8c7a2a 100644
--- a/integration-tests/ksp-companion/build.gradle
+++ b/integration-tests/ksp-companion/build.gradle
@@ -1,6 +1,6 @@
 plugins {
     id 'org.jetbrains.kotlin.jvm'
-    id("org.jetbrains.kotlin.ksp") version "1.4.0-dev-experimental-20200914"
+    id 'symbol-processing'
 }
 
 dependencies {
diff --git a/integration-tests/ksp/build.gradle b/integration-tests/ksp/build.gradle
index 9997d47..2a898d0 100644
--- a/integration-tests/ksp/build.gradle
+++ b/integration-tests/ksp/build.gradle
@@ -1,6 +1,6 @@
 plugins {
     id 'org.jetbrains.kotlin.jvm'
-    id("org.jetbrains.kotlin.ksp") version "1.4.0-dev-experimental-20200914"
+    id 'symbol-processing'
 }
 
 dependencies {