Open mpollmeier opened 6 years ago
@mpollmeier Thanks for your comment. antlr4
subdirectory path was added because of the issue in sbt-idea
plugin. You can see the commit log here: https://github.com/ihji/sbt-antlr4/commit/b706e722d57afb118cd42427649e170d26354d87
I think it's okay to remove antlr4
subdirectory path in the next version. It seems that many people are now using Intellij's native support of sbt
instead of sbt-idea
plugin.
Interesting how everything revolves around intellij on this issue. Thanks for the clarification, and the plugin :) Shall we leave this issue open as a reminder to remove, and in case others are having the same problem?
Is there a workaround for this? Can I just set javaSource in Antlr4 such that modern IntelliJ with the built-in SBT support will play nice?
I have found that
javaSource in Antlr4 := (sourceManaged in Compile).value
helps, but I still need to run sbt "antlr4:antlr4Generate"
to make IntelliJ happy.
Is there a better way to do this?
The recommendation is now against using (sourceManaged in Compile).value
altogether. Instead each plugin should roll out their own directory under target, and append to managedSourceDirectories in Compile
. See https://github.com/sbt/sbt/issues/1664#issuecomment-213057686
It looks to me like adding the antlr specific sources to sbt's
managedSourceDirectories
(https://github.com/ihji/sbt-antlr4/blob/3d36e6c/src/main/scala/com/simplytyped/Antlr4Plugin.scala#L80) isn't a good idea, since sbt already has the root directorysrc_managed
in the classpath (tested only with sbt 1.0.3). The resulting classpath contains the antlr generated sources twice then:src_managed
andsrc_managed/antlr4
.While sbt deals with that fine, Intellij compiles the classes twice and fails, complaining about "duplicate classes".
Changing this might be a can of worms though, and I haven't tested the zoo of different sbt versions and IDEs. Maybe it's best to just add a note in the readme? You probably know this topic better than me - what's your thoughts?