Maven SBT 依赖工件?

发布于 2024-10-22 02:40:12 字数 273 浏览 2 评论 0原文

我同时使用 Maven 和 SBT 管理我的项目。出现这种情况的原因是:

  1. Intellij IDEA 无法导入SBT 项目。(idea-sbt 插件没有 工作得很好)
  2. 我不知道如何获得来源和 来自 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:

  1. Intellij IDEA cannot import SBT
    project.(idea-sbt plugin doesn't
    work very well)
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅语花开 2024-10-29 02:40:12
  • 如果您将 pom.xml 放入项目的根目录,SBT 将识别它。当您在项目定义中未指定托管依赖项时,SBT 依赖于 Maven 依赖项。

    正如SBT 文档中所述,

sbt 执行此依赖性处理
当执行更新操作时。经过
默认情况下,sbt 不会更新您的
每次编译之前的依赖项,
但只有当你执行时才会这样做
更新。 sbt支持三种方式
指定这些依赖项:

* 项目定义中的声明
* Maven POM 文件
* ivy配置和设置文件
  • 到目前为止,Maven 对 SBT 一无所知(至少,到目前为止我还没有听说过任何插件),因此,在 Maven 和 SBT 中管理项目的最佳方法是通过以下方式生成 POM: SBT。有关更多详细信息,请参阅 SBT 到 Maven 转换器
  • 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,

sbt performs this dependency handling
when the update action is executed. By
default, sbt does not update your
dependencies before every compilation,
but only does so when you execute
update. sbt supports three ways of
specifying these dependencies:

* Declarations in your project definition
* Maven POM files
* Ivy configuration and settings files
  • Maven knows nothing about SBT as of now (at least, I've not heard about any plugins so far), so, the best you can do to manage your project both in Maven and SBT, is to generate POMs by SBT. See SBT to Maven Converter for more details.
忘年祭陌 2024-10-29 02:40:12

idea-sbt 插件非常适合我在 IDEA 10 中使用 - 它真正要做的就是在 IDE 中打开一个 SBT shell,而且它做得足够好。

如果您有兴趣将 Maven 排除在构建之外,您应该考虑的一个插件是 sbt-idea 插件 ( https://github.com/mpeltonen/sbt-idea)。这是一个很棒的插件,可以从 SBT 项目生成 IDEA 文件。使用起来再简单不过了。在 SBT 提示符下,运行以下命令:

*sbtIdeaRepo at http://mpeltonen.github.com/maven/
*idea is com.github.mpeltonen sbt-idea-processor 0.3.0
update
idea

注意星号 - 应包含它们。

此时,您可以在IDEA中打开您的项目。它不会抱怨 SBT 依赖性。每当您向项目文件添加新的依赖项时,只需再次运行“ide​​a”命令即可将其告知 IDEA。我在 idea-sbt 提供的 SB​​T 窗口中执行此操作。

至于获取具有依赖项的源代码和文档,您可以执行类似的操作(来自 SBT docs):

val sc = "org.scalacheck" % "scalacheck" % "1.5" withSources()

有一个对应的 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:

*sbtIdeaRepo at http://mpeltonen.github.com/maven/
*idea is com.github.mpeltonen sbt-idea-processor 0.3.0
update
idea

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):

val sc = "org.scalacheck" % "scalacheck" % "1.5" withSources()

There is a corresponding withJavadoc() method. Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文