linux下eclipse导入sbt项目

环境描述:

  1. centos6.6
  1. jdk1.7
  1. scala_IDE 4.4.1Eclipse
  1. scala语言环境
  1. 已有项目test,使用sbt创建,但目前无法使用eclipse导入该项目

 

安装步骤

  1. 下载sbthttp://www.scala-sbt.org/download.html
  2. 解压缩sbt压缩包
  1. 建立启动sbt的脚本文件

$ cd ./sbt

$ vim sbt

#sbt文本文件中添加如下信息:

SBT_OPTS="-Xms1536M-Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"

java $SBT_OPTS -jar /usr/local/sbt/bin/sbt-launch.jar "$@"

(路径需要根据自己的安装目录修改)

保存退出

赋予sbt可执行权限

chmod +x sbt

 

  1. 配置PATH环境变量

$ vim ~/.bashrc

#在文件尾部添加如下代码后,保存退出

export PATH=/usr/local/sbt/:$PATH

$ source ~/.bashrc

 

  1. 测试sbt是否安装成功

sbt sbt-version

初次启动会下载一下包,耗时较长,需保证联网

  1. github下载sbteclipse插件的zip包(https://github.com/typesafehub/sbteclipse
  2. 解压后,进入sbteclipse的根目录,使用sbt编译

cd /usr/local/sbteclipse-master

sbt

>compile

 

  1. 进入项目test的根目录,

1)修改project/build.properties中的sbt版本为当前机器安装的sbt版本号,我的是0.13.11

2)project/assembly.sbt中添加addSbtPlugin("com.typesafe.sbteclipse" %"sbteclipse-plugin" % "4.0.0"),这里的版本号也需要根据sbteclipse的版本号修改

  1. 进入在test项目的根目录,执行sbt命令

cd test

sbt

>eclipse

(需要下载一些包,耗时较长)

 

  1. 使用eclipse导入test项目即可。
  2. 编译时,进入test目录,启动sbt,执行compilepackage命令进行编译和打包,如果配置了assembly,则使用assembly命令打包,sbt本来就支持类似maven的编译打包命令

                                                                

clean

Deletes all generated files (in the target directory).

compile

Compiles the main sources (in src/main/scala and src/main/java directories).

test

Compiles and runs all tests.

console

Starts the Scala interpreter with a classpath including the compiled sources and all dependencies. To return to sbt, type :quit , Ctrl+D (Unix), or Ctrl+Z (Windows).

run *

Runs the main class for the project in the same virtual machine as sbt.

package

Creates a jar file containing the files in src/main/resources and the classes compiled from src/main/scala and src/main/java .

help

Displays detailed help for the specified command. If no command is provided, displays brief descriptions of all commands.

reload

Reloads the build definition ( build.sbt , project/*.scala , project/*.sbt files). Needed if you change the build definition.

  1. Assembly是作为一种插件的,所以要在project下面的plugins.sbt里面配置,addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")

你可能感兴趣的:(工程,eclipse,sbt)