如何使 sbt 项目引用外部 java 源
任何人都可以发布如何在 sbt 项目中引用外部 java 源目录的代码示例吗?
如果我执行以下操作,
override def mainSourceRoots = super.mainSourceRoots +++ externalsourcepath
sbt 编译任务将正确查找并编译 java 源代码,但随后会失败。例如
[info] Compilation successful.
java.lang.RuntimeException: Path /full/path/to/java/class/com/foo/bar/SomeClass.java not in .
Could anyone post a code example of how to reference an external java source directory in an sbt project?
If I do the following
override def mainSourceRoots = super.mainSourceRoots +++ externalsourcepath
the sbt compile task will properly find and compile the java sources but then fail. e.g.
[info] Compilation successful.
java.lang.RuntimeException: Path /full/path/to/java/class/com/foo/bar/SomeClass.java not in .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SBT 0.9 将支持外部子项目。在那之前,我建议将另一个构建为 JAR,并将结果放入
./lib
中。SBT 0.9 will support external sub-projects. Until then, I would suggest to build the other one to a JAR, and drop the results into
./lib
.如果 Java 项目使用 Maven 或 Ivy,您可以在本地安装它们并将它们声明为 SBT 项目中的依赖项。如果你需要像 Maven 的 Reactor 这样的东西,你可以在同一个超级项目中混合 Java 和 Scala 子模块,并同时按顺序编译它们,你可以尝试 SBT 子项目
If the Java projects use Maven or Ivy you can probably install them locally and declare them as dependencies in the SBT project. If you need something like Maven's reactor where you can mix Java and Scala submodules within the same super project, and compile them in order at the same time, you can try SBT Subprojects