加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何让sbt下载scala-library.jar的源码?

发布时间:2020-12-16 09:17:48 所属栏目:安全 来源:网络整理
导读:我知道如果我添加withSources当我定义一个依赖项,sbt可以自动下载源jar文件. 例如, val specs = “org.scala-tools.testing” % “specs_2.8.1” % “1.6.6” % “test” withSources () 但是对于scala-library.jar和scala-compiler.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生成想法项目后,我不需要手动配置.

解决方法

您必须更改启动属性.在 Mathias的最新博客 decodified中有一个很好的描述:
“ How to make SBT download scala library sources”(从 @hseeberger起始点开始)

这是相关的部分(万一链接过时)

First,forget about trying to find some “hidden” setting in your SBT project definition enabling Scala library source download! It does not exist (at least not in SBT version 0.7.x).
Rather,there are these two things you need to do in order to whip SBT into submission:

  1. Create an alternative configuration file for your SBT launcher.
  2. Make the SBT launcher use it.

These are the steps in detail:

  • Find your sbt-launcher-0.7.x.jar file.
    Since I’m on OS/X and use SBT via Homebrew mine lives at /usr/local/Cellar/sbt/0.7.5.RC0/libexec/sbt-launch-0.7.5.RC0.jar.
  • Extract the sbt.boot.properties from the sbt sub directory in the launcher jar
  • Fire up your favorite editor and change line 3 to classifiers: sources (uncomment the line)
  • Find the sbt script file you created during your SBT setup (e.g. ~/bin/sbt,or,when using Homebrew,/usr/local/Cellar/sbt/0.7.x/bin/sbt)
  • Add the path to your tweaked sbt.boot.properties file,prepended with an ’@’ character and in double quotes,as the second-to-last argument of the java call.

This is what my sbt script file looks like:

#!/bin/sh
java -Xmx768M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m 
     -jar /usr/local/Cellar/sbt/0.7.5.RC0/libexec/sbt-launch-0.7.5.RC0.jar 
     "@/usr/local/Cellar/sbt/0.7.5.RC0/libexec/sbt.boot.properties" 
     "$@"

Once you have completed these steps SBT should happily download the scala-...-sources.jar files for the Scala compiler and standard library for any new project you create.
To have SBT do this for an existing project,you have to manually delete the project/boot/scala-{version} directory before performing an ‘sbt update’ (SBT does not fetch additional source artifacts if the main jar is already present).

一旦你有一个自定义的sbt.boot.properties文件,还有其他方法提供给SBT启动器.

看到这个问题“how do I get sbt to use a local maven proxy repository (Nexus)?”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读