Skip to content

Commit b9dca93

Browse files
Virelionting-yuan
authored andcommitted
Fix NullPointerException on adding plugin to KMP project
1 parent 3ce960e commit b9dca93

File tree

1 file changed

+2
-1
lines changed
  • gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle

1 file changed

+2
-1
lines changed

gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
8383

8484
override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> {
8585
val project = kotlinCompilation.target.project
86-
val kotlinCompileProvider: TaskProvider<KotlinCompile> = project.locateTask(kotlinCompilation.compileKotlinTaskName)!!
86+
val kotlinCompileProvider: TaskProvider<KotlinCompile> = project.locateTask(kotlinCompilation.compileKotlinTaskName)
87+
?: return project.provider { emptyList() }
8788
val javaCompile = findJavaTaskForKotlinCompilation(kotlinCompilation)?.get()
8889
val kspExtension = project.extensions.getByType(KspExtension::class.java)
8990

0 commit comments

Comments
 (0)