From 8b3aa3dc7f98615eb1d361804a40f67bfb9faf81 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Mon, 18 Jun 2018 21:11:49 +0300 Subject: [PATCH] as32: Kapt: 'kapt.kotlin.generated' is not marked as source root in Android Studio (#KT-24449) --- .../kapt/idea/KaptProjectResolverExtension.kt.as32 | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/kapt3/kapt3-idea/src/org/jetbrains/kotlin/kapt/idea/KaptProjectResolverExtension.kt.as32 b/plugins/kapt3/kapt3-idea/src/org/jetbrains/kotlin/kapt/idea/KaptProjectResolverExtension.kt.as32 index c27a38c1523..c977d075238 100644 --- a/plugins/kapt3/kapt3-idea/src/org/jetbrains/kotlin/kapt/idea/KaptProjectResolverExtension.kt.as32 +++ b/plugins/kapt3/kapt3-idea/src/org/jetbrains/kotlin/kapt/idea/KaptProjectResolverExtension.kt.as32 @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.kapt.idea +import com.android.ide.common.gradle.model.IdeBaseArtifact import com.android.tools.idea.gradle.project.model.AndroidModuleModel import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.externalSystem.model.DataNode @@ -117,15 +118,9 @@ class KaptProjectResolverExtension : AbstractProjectResolverExtension() { val androidModel = androidModelAny.data as? AndroidModuleModel ?: return val variant = androidModel.findVariantByName(sourceSet.sourceSetName) ?: return - androidModel.registerExtraGeneratedSourceFolder(generatedKotlinSources) - - // TODO remove this when IDEA eventually migrate to the newer Android plugin - try { - variant.mainArtifact.generatedSourceFolders += generatedKotlinSources - } catch (e: Throwable) { - // There was an error being thrown here, but the code above doesn't work for the newer versions of Android Studio 3 - // (generatedSourceFolders returns a wrapped unmodifiable list), and the thrown exception breaks the import. - // The error will be moved back when I find a work-around for AS3. + val mainArtifact = variant.mainArtifact + if (mainArtifact is IdeBaseArtifact) { + mainArtifact.addGeneratedSourceFolder(generatedKotlinSources) } } }