kobalt-intellij-plugin icon indicating copy to clipboard operation
kobalt-intellij-plugin copied to clipboard

Generated classes are not in the classpath in IntelliJ

Open sargunv opened this issue 9 years ago • 5 comments
trafficstars

Generated classes don't show up in the classpath in IntelliJ, causing "Cannot resolve symbol" errors. See this sample project: https://github.com/sargunster/annotations where the project builds in Kobalt but shows compile errors in IntelliJ.

One possible solution is to mark the kobaltBuild/classes as a "generated sources root".

sargunv avatar Jun 01 '16 22:06 sargunv

You need to take a few extra steps to declare your annotation processor to IDEA, I don't think this has anything to do with Kobalt.

And I don't think the Kobalt IDEA plug-in can do much since, as you saw, there is no mention of apt in your Build.kt, so the plug-in has no way of knowing you're using an annotation processor (short of doing a lot of costly introspection).

Here is the relevant doc.

cbeust avatar Jun 01 '16 22:06 cbeust

Thanks, I'll have a look at the doc. The Gradle plugin doesn't require any additional configuration for annotation processing.

sargunv avatar Jun 01 '16 22:06 sargunv

Ok let's dig a bit further, then. The Kobalt plug-in could see if the project contains any annotation processor file under META-INF and configure the IDE automatically.

@dmitry-zhuravlev Thoughts?

cbeust avatar Jun 01 '16 22:06 cbeust

I think the simplest solution is to mark the outputDir in apt as a generated sources root.

sargunv avatar Jun 01 '16 23:06 sargunv

I think the simplest solution is to mark the outputDir in apt as a generated sources root.

Agree, but in this case information about defined outputDir should comes from server because plugin should know the actual outputDir defined in Build.kt

@cbeust Also I noticed that if no outputDir defined in Build.kt Kobalt produce generated sources in classes folder: image

I think that this should be placed in "kobaltBuild/generated/source/apt" just to not mix "java" and "class" files in same place. @cbeust What do you think?

dmitry-zhuravlev avatar Jun 02 '16 12:06 dmitry-zhuravlev