我刚开始开发Scala / LiftWeb / Sbt,我想在IntelliJ Idea中导入一个Sbt项目。实际上,我设法通过两种不同的方式导入我的项目:
1)和Maven一起。我创建了一个Maven项目,最重要的是创建了一个Sbt项目,然后将其导入IntelliJ中。然后,我可以轻松启动,停止码头服务器,并执行其他操作。但这不是我想要的。我想做同样的事情,只是没有Maven。那导致我
2)用Eclipse。因此,我创建了一个新的Sbt项目(使用编写的小脚本,将Sbt项目配置为WebProject)。然后,我使用sbt-eclipsify插件为Eclipse“转换”了项目,然后将其导入IntelliJ(现有源-> eclipse)中。但是问题从这里开始:我无法使IntelliJ Sbt插件正常工作。
谁能帮我这个?
共有三种创建项目的基本方法-IntelliJ的现代版本可以直接导入sbt项目,否则,您可以使用sbt插件生成IntelliJ项目,也可以使用IntelliJ Scala插件创建sbt项目。使用这两种解决方案都可以立即使用基本功能,某些复杂的版本可能会出现问题,因此请尝试使用其他工具查看是否可以正常使用。
如今,IntelliJ IDEA变得越来越好。当前版本(14.0.2)使用Scala插件支持sbt项目。只需安装插件,您就可以轻松打开Scala / sbt项目。
使用该插件,只需指向一个sbt项目,IDEA就会为您提供一个向导来打开这种项目。
IntelliJ插件可在http://confluence.jetbrains.com/display/SCA/Scala+Plugin+for+IntelliJ+IDEA上找到,也可以使用设置->插件对话框直接在IDE中安装。之后,只需执行File-> New Project-> Scala-> SBT。IntelliJ将生成基本的build.sbt,下载必要的依赖项并打开项目。
Sbt plugin that generate an idea project based on the sbt files can be found here: https://github.com/mpeltonen/sbt-idea
SBT 12.0+ & 13.0+
Simply add addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
to your build.sbt
; no additional resolvers are needed.
SBT 0.11+
Create and add the following lines to ~/.sbt/plugins/build.sbt
OR PROJECT_DIR/project/plugins.sbt
resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/" addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
Use gen-idea
in sbt to create IDEA project files.
By default, classifiers (i.e. sources and javadocs) of sbt and library dependencies are loaded if found and references added to IDEA project files. If you don't want to download/reference them, use command gen-idea no-classifiers no-sbt-classifiers
.
SBT 0.10.1 (according to the plugin author, 0.10.0 won't work!)
Create and add the following lines to ~/.sbt/plugins/build.sbt:
resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"
libraryDependencies += "com.github.mpeltonen" %% "sbt-idea" % "0.10.0"
使用gen-idea
sbt任务创建IDEA项目文件。
默认情况下,如果找到sbt和库依赖项的分类器(即源和javadocs),并将引用添加到IDEA项目文件中。如果您不想下载/引用它们,请使用command gen-idea no-classifiers no-sbt-classifiers
。
SBT 0.7
要使用它,只需在您的sbt shell中运行它,它将插件用作外部程序:
> *sbtIdeaRepo at http://mpeltonen.github.com/maven/
> *idea is com.github.mpeltonen sbt-idea-processor 0.4.0
...
> update
...
> idea
...
您还可以根据需要在项目定义中添加特征:
import sbt._
class MyProject(info: ProjectInfo) extends ParentProject(info) with IdeaProject {
lazy val mySubProject = project("my-subproject", "my-subproject", new DefaultProject(_) with IdeaProject)
// ...
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句