as32: Kapt: 'kapt.kotlin.generated' is not marked as source root in Android Studio (#KT-24449)
This commit is contained in:
+4
-9
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.kapt.idea
|
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.android.tools.idea.gradle.project.model.AndroidModuleModel
|
||||||
import com.intellij.openapi.diagnostic.Logger
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
import com.intellij.openapi.externalSystem.model.DataNode
|
import com.intellij.openapi.externalSystem.model.DataNode
|
||||||
@@ -117,15 +118,9 @@ class KaptProjectResolverExtension : AbstractProjectResolverExtension() {
|
|||||||
val androidModel = androidModelAny.data as? AndroidModuleModel ?: return
|
val androidModel = androidModelAny.data as? AndroidModuleModel ?: return
|
||||||
val variant = androidModel.findVariantByName(sourceSet.sourceSetName) ?: return
|
val variant = androidModel.findVariantByName(sourceSet.sourceSetName) ?: return
|
||||||
|
|
||||||
androidModel.registerExtraGeneratedSourceFolder(generatedKotlinSources)
|
val mainArtifact = variant.mainArtifact
|
||||||
|
if (mainArtifact is IdeBaseArtifact) {
|
||||||
// TODO remove this when IDEA eventually migrate to the newer Android plugin
|
mainArtifact.addGeneratedSourceFolder(generatedKotlinSources)
|
||||||
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.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user