如何让sbt下载scala-library.jar的源码?
我知道如果我在定义一个依赖项时添加 withSources,sbt 可以自动下载该源 jar 文件。 例如,
val specs = "org.scala-tools.testing" % "specs_2.8.1" % "1.6.6" % "test" withSources ()
但是对于 scala-library.jar 和 scala-compiler.jar,我不这样做需要明确定义它们,我怎样才能让 sbt 为我下载它们的源代码?因此,在使用 sbt-idea-plugin 生成 idea 项目后,我不需要手动配置它。
I know if I add withSources when I define one dependency, sbt can download that sources jar file automatically.
For example,
val specs = "org.scala-tools.testing" % "specs_2.8.1" % "1.6.6" % "test" withSources ()
But for the scala-library.jar and scala-compiler.jar, I don't need define them explicitly, how can I get sbt download their sources for me? So, I don't need config it manually after generate idea project using sbt-idea-plugin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须更改启动属性。最近的博客 decodeified 来自 马蒂亚斯:
“如何让 SBT 下载 scala 库源”(从 @hseeberger 关键起点开始)
这是相关部分(以防链接过时)
一旦您拥有自定义 sbt.boot.properties 文件,还可以通过其他方式将其提供给 SBT 启动器。
请参阅SO问题“如何让 sbt 使用本地 Maven 代理存储库 (Nexus)?"
You have to change the boot properties. There is a nice description in the recent blog decodified from Mathias:
"How to make SBT download scala library sources" (started from @hseeberger key starting points)
Here is the relevant part (in case that link ever goes stale)
Once you have a custom
sbt.boot.properties
file, there are also other ways to supply it to the SBT launcher.See SO question "how do I get sbt to use a local maven proxy repository (Nexus)?"
根据 Michael Slinn 的评论:
如果您使用 sbt 0.11.x 及更高版本,请使用以下命令:
Based on Michael Slinn comments:
If you are using sbt 0.11.x and above, use this command:
两条信息。
(1) SBT文档
http://www.scala-sbt.org /0.13.5/docs/Detailed-Topics/Library-Management.html
我引用:
“要以传递方式获取所有依赖项的特定分类器,请运行 updateClassifiers 任务。默认情况下,这将解析具有源或 javadoc 分类器的所有工件。”
这意味着您不需要执行任何操作,但您可以将其明确并放入 build.sbt 中:
transitiveClassifiers := Seq("sources", "javadoc")
要实际获取 SBT 下载的源代码,请执行以下操作:
(2) 如果您正在使用 Eclipse scala IDE - 最有可能的是,因为 Eclipse/Netebeans 插件的开发对于 eclipse 来说更加活跃 - 那么您应该配置您的 ecplise 来找出源代码,如果您执行以下操作下列的。
EclipseKeys.withSource := true
这是您应该阅读的文档,
https://github.com/typesafehub/sbteclipse/wiki/Using-sbteclipse
Two pieces of information.
(1) SBT Documentation
http://www.scala-sbt.org/0.13.5/docs/Detailed-Topics/Library-Management.html
and I quote:
"To obtain particular classifiers for all dependencies transitively, run the updateClassifiers task. By default, this resolves all artifacts with the sources or javadoc classifier."
This means you should not need to do anything, but you can make it explicit and put in you build.sbt:
transitiveClassifiers := Seq("sources", "javadoc")
To actually get the sources downloaded by SBT then you do:
(2) If you are working with Eclipse scala IDE - most likely you are as development of plugins for Eclipse/Netebeans is a lot more active for eclipse - then you should configure your ecplise to find out the sources if you do the following.
EclipseKeys.withSource := true
Here is the documentation you should read,
https://github.com/typesafehub/sbteclipse/wiki/Using-sbteclipse