@@ -34,10 +34,10 @@ import io.spine.tools.fs.DirectoryName.grpc
3434import io.spine.tools.fs.DirectoryName.java
3535import io.spine.tools.fs.DirectoryName.kotlin
3636import io.spine.tools.gradle.project.findKotlinCompileFor
37+ import io.spine.tools.gradle.project.sourceSet
3738import io.spine.tools.gradle.project.sourceSets
38- // import io.spine.tools.gradle.project.sourceSet
3939import io.spine.tools.gradle.protobuf.generated
40- // import io.spine.tools.gradle.protobuf.generatedDir
40+ import io.spine.tools.gradle.protobuf.generatedDir
4141import io.spine.tools.gradle.protobuf.generatedSourceProtoDir
4242import io.spine.tools.gradle.task.findKotlinDirectorySet
4343import io.spine.tools.mc.java.ksp.gradle.KspBasedPlugin.Companion.autoServiceKsp
@@ -240,25 +240,14 @@ private fun Project.makeCompileKotlinTasksDependOnKspTasks() {
240240}
241241
242242/* *
243- * **DOES NOTHING** until [File.toRelativeString] correctly supports the calculation
244- * of a relative directory in a way we need for the replacement of
245- * the [outputBaseDir][com.google.devtools.ksp.gradle.KspGradleConfig.outputBaseDir]
246- * we want to make in this function.
247- *
248- * Another issue with [File.toRelativeString] is that it does not handle
249- * [different file path roots](https://github.com/google/ksp/issues/1079).
250- *
251- * -------
252243 * The function replaces default destination directory defied by
253244 * [com.google.devtools.ksp.gradle.KspGradleSubplugin.getKspOutputDir] to
254245 * the one we used for all the generated code at the level of the project root.
255246 *
256247 * Also `kotlin` directory set for each source set gets new generated
257248 * Kotlin and Java source directories as its inputs.
258249 */
259- @Suppress(" UnusedReceiverParameter" )
260250private fun Project.replaceKspOutputDirs () {
261- /*
262251 afterEvaluate {
263252 val underBuild = KspGradlePlugin .defaultTargetDirectory(it).toString()
264253 val underProject = generatedDir.toString()
@@ -267,18 +256,23 @@ private fun Project.replaceKspOutputDirs() {
267256 outputBaseDir.replace(underBuild, underProject)
268257 kotlinOutputDir.replace(underBuild, underProject)
269258 javaOutputDir.replace(underBuild, underProject)
259+ resourceOutputDir.replace(underBuild, underProject)
260+
261+ val sourceSet = sourceSet(ssn)
262+ sourceSet.run {
263+ // KSP Gradle Plugin already added its output to source sets.
264+ // We need to add the replacement manually because we filtered
265+ // it before in `Project.makeKspIgnoreGeneratedSourceProtoDir()`.
266+
267+ java.srcDirs(javaOutputDir)
268+ findKotlinDirectorySet()?.srcDirs(kotlinOutputDir)
270269
271- // KSP Gradle Plugin already added its output to source sets.
272- // We need to add the replacement manually because we filtered
273- // it before in `Project.excludeSourcesFromBuildDir()`.
274- sourceSet(ssn).findKotlinDirectorySet()?.run {
275- srcDirs(kotlinOutputDir)
276- srcDirs(javaOutputDir)
270+ // We need to add redirected KSP-generated resources too.
271+ resources.srcDirs(resourceOutputDir)
277272 }
278273 }
279274 }
280275 }
281- */
282276}
283277
284278/* *
0 commit comments