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) } } }