Skip to content

Commit

Permalink
Set destinationDir for KotlinCompileTaskData.
Browse files Browse the repository at this point in the history
  • Loading branch information
ting-yuan committed Nov 6, 2020
1 parent a850711 commit ae98b8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.google.devtools.ksp.gradle;

import org.gradle.api.provider.Provider;
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation;
import org.jetbrains.kotlin.gradle.tasks.KotlinCompileTaskData;

import java.io.File;

// FIXME: Ask upstream to open these API
public class InternalTrampoline {
public static void KotlinCompileTaskData_register(String taskName, KotlinCompilation<?> kotlinCompilation) {
public static void KotlinCompileTaskData_register(String taskName, KotlinCompilation<?> kotlinCompilation, Provider<File> destinationDirProvider) {
KotlinCompileTaskData kotlinCompileTaskData = KotlinCompileTaskData.Companion.register(taskName, kotlinCompilation);
kotlinCompileTaskData.getDestinationDir().set(destinationDirProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool

assert(kotlinCompileProvider.name.startsWith("compile"))
val kspTaskName = kotlinCompileProvider.name.replaceFirst("compile", "ksp")
InternalTrampoline.KotlinCompileTaskData_register(kspTaskName, kotlinCompilation)
val destinationDir = File(project.buildDir, "generated/ksp")
InternalTrampoline.KotlinCompileTaskData_register(kspTaskName, kotlinCompilation, project.provider { destinationDir })

val kspTaskProvider = project.tasks.register(kspTaskName, KspTask::class.java) { kspTask ->
kspTask.setDestinationDir(File(project.buildDir, "generated/ksp"))
kspTask.setDestinationDir(destinationDir)
kspTask.mapClasspath { kotlinCompileProvider.get().classpath }
kspTask.options = options
kspTask.outputs.dirs(kotlinOutputDir, javaOutputDir, classOutputDir)
Expand Down

0 comments on commit ae98b8c

Please sign in to comment.