sbt笔记三 用IDEA和Eclipse开发sbt项目

准备

标题中提到的两个是我正在用,也比较经常使用的IDE。

首先把咱们以前的项目hello-sbt复制两份,分别叫hello-sbt-idea和hello-sbt-eclipse。 git

添加插件

有两个插件能够把sbt项目转换为idea项目和eclipse项目。

在hello-sbt-idea/project/下建立plugin.sbt文件,内容为:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
// 2013/10/28

一样的,在hello-sbt-eclipse/project/下建立plugin.sbt文件,内容为: github

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0") 
// 2013/10/28

(若是sbt已经在运行了,就reload一下)


导入项目到IDEA

在hello-sbt-idea/下打开命令行,执行:
$sbt
> gen-idea
完成后,项目根目录下生成了.idea和.idea_modules文件

启动IDEA,选择打开项目,能够看到idea已经识别出hello-sbt-idea了。

再看一下包结构
shell

根目录下的project文件夹(图中选中项)被转换成一个模块
eclipse

导入项目到Eclipse

在hello-sbt-eclipse/下打开命令行,执行:
$sbt
> eclipse
完成后,熟悉的.project和.classpath文件出现了。

导入成功
相关文章
相关标签/搜索