-
Notifications
You must be signed in to change notification settings - Fork 931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sort out situation for managed Java sources #1664
Comments
This may be something for sbt/website, but let's look at the build itself, as I think we're weak in Java setup. |
sbt-cxf-wsdl2java has actually been following the documentation for generating Java sources and I haven't had any build problems in Sbt, things do break in IDEA when "correct" (as per the documentation) plugins get combined with ones that just generate their sources straight under sourceManaged. The plugin does this though: |
In the hindsight, the idea that multiple plugins sharing the What do you guys think about adding some facility in the auto plugin that could generate sources safely? package sbthello
import sbt._
import Keys._
object HelloPlugin extends AutoPlugin {
override def requires = plugins.JvmPlugin
override def managedDirectoryName = Some("hello")
override lazy val projectSettings = Seq(
sourceGenerators in Compile += Def.task {
val file = pluginManagedSource(this, Compile).value / "Test.scala"
IO.write(file, """object Test extends App { println("Hi") }""")
Seq(file)
}.taskValue
)
} |
We should get a quick solution for this for short term and good solution for this in the long run. Currently the situation makes auto import of sbt project in IntelliJ almost broken. |
The short-term workaround might be to recommend against using |
…short term. Closes ebiznext#11. See sbt/sbt#1664 (comment)
The solution @eed3si9n suggested seems to work well. I finally got around to trying it in sbt/sbt-xjc@4a0c67c. I've released a new version (0.10) of sbt-xjc with the fix |
The sbt documentation says:
This works fine for generating Scala sources, but not generating Java sources. The reason is, the Java compiler needs a concept of a compilation root directory, and the one that sbt gives it for all sources in
sourceManaged
issourceManaged
, not sub directories ofsourceManaged
. Since the Java package structure must match the Java directory structure, this means in order for the Java generated source files to compile, their package structure needs to be directly undersourceManaged
, not a sub directory ofsourceManaged
.So this causes confusion, for example, sbt-idea follows the documentation, and treats sub directories of
sourceManaged
as source directories, which causes any Java files generated insourceManaged
to not compile from IntelliJ's perspective. See mpeltonen/sbt-idea#257. This causes a problem particularly with Play, see playframework/playframework#2941.One possible solution is #753, but I think the documentation should simply be updated to say something like:
The text was updated successfully, but these errors were encountered: