Skip to content

Commit

Permalink
Pass generated resources directly to ProcessResources task
Browse files Browse the repository at this point in the history
  • Loading branch information
ting-yuan committed Jan 12, 2021
1 parent f4ba7b0 commit 5dfa9fd
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.SourceSetOutput
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.language.jvm.tasks.ProcessResources
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.gradle.plugin.*
Expand Down Expand Up @@ -149,12 +150,12 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
kotlinCompile.classpath += project.files(classOutputDir)
}

// KotlinCompilationOutput assumes only one resource provider.
// Therefore, it's best not to override it in case of conflicting with other plugins.
// FIXME: Need KotlinCompilationOutput.dir() in upstream.
when (val outputs = kotlinCompilation.output.allOutputs) {
is ConfigurableFileCollection -> outputs.from(resourceOutputDir)
is SourceSetOutput -> outputs.dir(resourceOutputDir)
val processResourcesTaskName = (kotlinCompilation as? KotlinCompilationWithResources)?.processResourcesTaskName ?: "processResources"
project.locateTask<ProcessResources>(processResourcesTaskName)?.let { provider ->
provider.configure { resourcesTask ->
resourcesTask.dependsOn(kspTaskProvider)
resourcesTask.from(resourceOutputDir)
}
}

return project.provider { emptyList() }
Expand Down

0 comments on commit 5dfa9fd

Please sign in to comment.