Maven SBT 依赖工件?
我同时使用 Maven 和 SBT 管理我的项目。出现这种情况的原因是:
- Intellij IDEA 无法导入SBT 项目。(idea-sbt 插件没有 工作得很好)
- 我不知道如何获得来源和 来自 SBT 的 javadocs。(我想看到有关此问题的任何答案)
问题是我不知道如何让 Maven 下载 SBT 依赖项。我搜索了 Maven 存储库,但找不到任何有关 sbt 的信息。我想使用 Maven 或 SBT 来管理项目中的所有 jar。
I manage my project using Maven and SBT at same time. The reasons for this are:
- Intellij IDEA cannot import SBT
project.(idea-sbt plugin doesn't
work very well) - I don't know how can get sources and
javadocs from SBT.(I'd like to see any answers about this)
The problem is I don't know how to let Maven download SBT dependency. I search through maven repository and couldn't find anything about sbt. I wanna use Maven or SBT to manage all the jars in my project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您将 pom.xml 放入项目的根目录,SBT 将识别它。当您在项目定义中未指定托管依赖项时,SBT 依赖于 Maven 依赖项。
正如SBT 文档中所述,
If you put a pom.xml to the root of your project, it will be recognized by SBT. When you specify no managed dependencies in the project definition, SBT relies on Maven dependencies.
As it said in SBT doumentation,
idea-sbt 插件非常适合我在 IDEA 10 中使用 - 它真正要做的就是在 IDE 中打开一个 SBT shell,而且它做得足够好。
如果您有兴趣将 Maven 排除在构建之外,您应该考虑的一个插件是 sbt-idea 插件 ( https://github.com/mpeltonen/sbt-idea)。这是一个很棒的插件,可以从 SBT 项目生成 IDEA 文件。使用起来再简单不过了。在 SBT 提示符下,运行以下命令:
注意星号 - 应包含它们。
此时,您可以在IDEA中打开您的项目。它不会抱怨 SBT 依赖性。每当您向项目文件添加新的依赖项时,只需再次运行“idea”命令即可将其告知 IDEA。我在 idea-sbt 提供的 SBT 窗口中执行此操作。
至于获取具有依赖项的源代码和文档,您可以执行类似的操作(来自 SBT docs):
有一个对应的 withJavadoc() 方法。希望有帮助。
idea-sbt plugin works great for me with IDEA 10 - all it's really intended to do is open an SBT shell within the IDE and it does that well enough.
A plugin you should look into if you're interested in getting the Maven out of your build is sbt-idea plugin ( https://github.com/mpeltonen/sbt-idea ). This is a great plugin that generates IDEA files from an SBT project. It couldn't be easier to use. At an SBT prompt, run the following commands:
Note the asterisks - they should be included.
At this point, you can open your project in IDEA. It won't complain about the SBT dependencies. Any time you add new dependencies to your project file, simply run the 'idea' command again to tell IDEA about it. I do that in the SBT window provided by idea-sbt.
As far as getting sources and docs with dependencies, you can do something like this (from the SBT docs):
There is a corresponding withJavadoc() method. Hope that helps.