linux手动安装sbt过程


http://blog.csdn.net/zcf1002797280/article/details/49677881

1. 下载sbt安装包

下载地址点这里


2. 解压文件

tar zxvf sbt-0.13.9.tgz

3. 建立启动sbt的脚本文件

./sbt目录下面新建文件名为sbt的文本文件

<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">cd</span> ./sbt
$ vim sbt
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;"># 在sbt文本文件中添加如下信息:</span>
BT_OPTS=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"</span>
java <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$SBT_OPTS</span> -jar /home/zhangchengfei/Tools/sbt/bin/sbt-launch.jar <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$@</span>"</span> </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li></ul>

这里路径需要需改为你自己对应的文件路径,只要能够正确的定位到解压的sbt文件包中的sbt-launch.jar文件即可

修改sbt文件权限

$ chmod u+x sbt 

4. 配置PATH环境变量

<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ vim ~/.bashrc
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;"># 在文件尾部添加如下代码后,保存退出</span>
<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> PATH=/home/zhangchengfei/Tools/sbt/:<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$PATH</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

使配置文件立刻生效

$ source ~/.bashrc

5. sbt设置

  • 配置文件的目录在./sbt/conf/sbtconfig.txt

  • 设置网络代理,在配置中添加:

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">-Dhttp<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.proxyHost</span>=proxy<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.zte</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.com</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.cn</span>
-Dhttp<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.proxyPort</span>=<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">80</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
  • 安装完成后会在用户的根目录生成两个文件夹,sbt工作文件夹.sbt和lvy缓存目录.ivy2,修改默认路径,在配置中添加:
<code class="hljs haml has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">-<span class="ruby" style="box-sizing: border-box;"><span class="hljs-constant" style="box-sizing: border-box;">Dsbt</span>.global.base=<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/home/zhangchengfei</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/Tools/sbt</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/.sbt
</span></span>-<span class="ruby" style="box-sizing: border-box;"><span class="hljs-constant" style="box-sizing: border-box;">Dsbt</span>.ivy.home=<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/home/zhangchengfei</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/Toos/sbt</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/.ivy2</span></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

注意:上面这种方式修改路径我尝试过并没有成功,网上说需要重启系统才能生效。由于电脑当前状态信息太多(开的应用太多)重启后很难恢复,并且这并不影响实验结果,所以没有进一步测试验证。


6. 测试sbt是否安装成功

第一次执行时,会下载一些文件包,然后才能正常使用,要确保联网了,安装成功后显示如下

<code class="hljs sql has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ sbt sbt-version
[info] <span class="hljs-operator" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Set</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">current</span> project <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> sbt (<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">in</span> build file:/opt/scala/sbt/)
[info] <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.13</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.9</span></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

【完】


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值