From 9f68d9d803c006dc6b2f2926c91f3ee9248cf1a0 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 3 Oct 2022 16:42:17 +0200 Subject: [PATCH] Workaround to have KSP generated Kotlin code available in the IDE (for code completion) Ref: https://github.com/airbnb/epoxy/releases/tag/5.0.0beta02 --- build.gradle | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/build.gradle b/build.gradle index cfcca7925c..6461f63c00 100644 --- a/build.gradle +++ b/build.gradle @@ -329,3 +329,31 @@ ext.initScreenshotTests = { project -> } } } + +// Workaround to have KSP generated Kotlin code available in the IDE (for code completion) +// Ref: https://github.com/airbnb/epoxy/releases/tag/5.0.0beta02 +subprojects { project -> + afterEvaluate { + if (project.hasProperty("android")) { + android { + if (it instanceof com.android.build.gradle.LibraryExtension) { + libraryVariants.all { variant -> + def outputFolder = new File("build/generated/ksp/${variant.name}/kotlin") + variant.addJavaSourceFoldersToModel(outputFolder) + android.sourceSets.getAt(variant.name).java { + srcDir(outputFolder) + } + } + } else if (it instanceof com.android.build.gradle.AppExtension) { + applicationVariants.all { variant -> + def outputFolder = new File("build/generated/ksp/${variant.name}/kotlin") + variant.addJavaSourceFoldersToModel(outputFolder) + android.sourceSets.getAt(variant.name).java { + srcDir(outputFolder) + } + } + } + } + } + } +}