mpeltonen / sbt-idea

A simple-build-tool (sbt) plugin/processor for creating IntelliJ IDEA project files
Other
1.07k stars 153 forks source link

Is there a way to mark `gen` as Generated Sources Root after SBT refresh? #311

Open drhr opened 10 years ago

drhr commented 10 years ago

Sorry if this is the wrong place to ask this, but I wondered if the sbt-idea plugin could somehow solve this problem I'm having.

I have an Android project that I'm importing into IntelliJ with the help of sbt-idea. It uses android-sdk-plugin and a build.sbt configuration file. The problem is that if you link IntelliJ's SBT up to the project (to automatically refresh the build when you make changes to your build.sbt configuration), it basically removes the "Generated Sources Root" designation from the gen directory, which as you might already know is an important source directory that the rest of your Android source code needs in order to identify resources like layouts, images, etc. So every time this SBT refresh happens, I have to right-click gen and Mark Directory As "Generated Source Root".

I tried adding this line to the end of build.sbt:

ideaSourcesClassifiers += "gen"

but I think I'm barking up the wrong tree with that one.

Does anyone have any thoughts?

drhr commented 10 years ago

Update on this: It's not too big of a deal. It really only happens when you update build.sbt or manually refresh the SBT project associated with your IDEA project. I actually started up another project recently as a desktop application and noticed something very similar - the various Source Roots would get redefined, which would break all the package names in imports in all my source files. Seems like more of an IDEA issue than SBT, but figured somebody has run into this already and perhaps solved it.

jozic commented 10 years ago

that sounds like IDEA issue, try to disable auto-import of changes in IDEA SBT settings

tobiberger commented 9 years ago

I still don't know how to mark a directory as generated sources root, but I got sbt to mark it as a source root in general, which is good enough for avoiding errors in your IDE. just add this to you build.sbt: managedSourceDirectories in Compile += baseDirectory.value / "gen"