as32: Kapt: 'kapt.kotlin.generated' is not marked as source root in Android Studio (#KT-24449)

This commit is contained in:
Yan Zhulanow
2018-06-18 21:11:49 +03:00
parent b2938ceacf
commit 8b3aa3dc7f
@@ -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)
}
}
}