score:171
There are three basic ways how to create a project - modern versions of IntelliJ can import sbt project out of the box, otherwise you can either use sbt plugin to generate IntelliJ project, or use IntelliJ Scala plugin to create sbt project. Basic features work out of the box using both solutions, some complex builds can have problems, so try other tools to see if it works there.
IntelliJ
IntelliJ IDEA has become so much better these days. The current version (14.0.2) supports sbt projects out of the box with the Scala plugin. Just install the plugin and you should be able to open up Scala/sbt projects without any troubles.
With the plugin, just point at a sbt project and IDEA is going to offer you a wizard to open that kind of project.
IntelliJ Scala Plugin
IntelliJ plugin can be found here http://confluence.jetbrains.com/display/SCA/Scala+Plugin+for+IntelliJ+IDEA or can be installed directoly from within the IDE using Settings -> Plugins dialog. Afterwards one can just do File -> New Project -> Scala -> SBT based. IntelliJ will generate basic build.sbt, download necessary dependencies and open project.
SBT Plugin
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.
Older Versions:
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"
Use gen-idea
sbt task 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.7
To use it, simply run this from your sbt shell, it will use the plugin as an external program:
> *sbtIdeaRepo at http://mpeltonen.github.com/maven/
> *idea is com.github.mpeltonen sbt-idea-processor 0.4.0
...
> update
...
> idea
...
You can also add trait in your project definition, as you want:
import sbt._
class MyProject(info: ProjectInfo) extends ParentProject(info) with IdeaProject {
lazy val mySubProject = project("my-subproject", "my-subproject", new DefaultProject(_) with IdeaProject)
// ...
}
score:0
Before you start creating your SBT project, make sure that the Scala plugin is downloaded and enabled in IntelliJ IDEA.
below link explains everything you need to know.
https://www.jetbrains.com/help/idea/2016.1/getting-started-with-sbt.html
score:2
I just went through all this pain. I spend days trying to get an acceptable environment up and have come to the conclusion that ENSIME, SBT and JRebel are going to be my development environment for some time. Yes, it is going back to Emacs, but ENSIME turns it into a bit or an idea with refactoring, debugging support, navigation, etc. It's not nowhere near as good as Eclipse (Java), but unless the scala plugins work better it's the best we have.
Until the Scala development environments get up to snuff (Eclipse or IntelliJ) I'm not going to bother. They're just way too buggy.
See the discussion on the lift site.
http://groups.google.com/group/liftweb/browse_thread/thread/6e38ae7396575052#
Within that thread, there is a link to a HOWTO for IntelliJ, but although it kinda works, there are many issues that render it a little less that useful.
http://blog.morroni.com/2010/07/14/setup-intellij-9-for-lift-framework-development/comment-page-1/
score:2
The answers are old for 2014. In IntelliJ 13.x, the plugin Scala is ver 0.41.2 ( SBT is included).
My SBT version is 0.13.5 (terminal : sbt sbtVersion
)
Go to the project's root folder and enter in the terminal
sbt idea
You will see two new hidden folders .idea and .idea_modules.
Then in IntelliJ, File > Open > select the project. It should open the project without any problem.
score:5
For sbt 0.7
See the answer elsewhere on this page.
For sbt 0.10
Clone and build Ismael's sbt-idea:
git clone https://github.com/ijuma/sbt-idea.git
cd sbt-idea
git checkout sbt-0.10
./sbt package
Create an sbt plugin lib directory if you don't have one already
mkdir -p ~/.sbt/plugins/lib
Copy the jar built in step one into here
cp sbt-idea/target/scala-2.8.1.final/*.jar ~/.sbt/plugins/lib
Restart or reload sbt, then you can run gen-idea
(or gen-idea with-classifiers
if you want sources and javadoc in intelliJ too)
Source: Tackers' suggestion on the message group.
In IntelliJ IDEA 13.x itself
You can open an SBT-based project in IDEA nowadays. It will create the necessary project and modules, and keep your dependencies up-to-date whenever you make changes to the build scripts.
score:7
Tempus fugit and IntelliJ IDEA has become so much better these days. It's 2015 after all, isn't it?
Having said that, the latest version of IntelliJ IDEA 14.0.2 supports sbt projects out of the box with the Scala plugin. Just install the plugin and you should be able to open up Scala/sbt projects without much troubles.
I'm using the Early Access version of the plugin which is 1.2.67.6.EAP as of the time of the writing.
With the plugin just point at a sbt project and IDEA is going to offer you a wizard to open that kind of project.
About sbt-idea in sbt 0.12.4
For sbt 0.12.4 the system-wide plugin configuration file - ~/.sbt/plugins/build.sbt
or PROJECT_DIR/project/plugins.sbt
- should have the following lines:
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin(dependency="com.github.mpeltonen" % "sbt-idea" % "1.5.0-SNAPSHOT")
Run sbt gen-idea
to generate IDEA project files.
Read the sbt-idea plugin website for more up-to-date information. You may also find my blog entry Importing sbt-based project to IntelliJ IDEA 13 (with sbt-idea, Scala 2.11 and sbt 0.12) useful.
score:11
For now I do this by hand. It is quite simple.
- Create the project with SBT
- Create a new IDEA Project with the same root path
- Create a module with the same root path
- Set src/main/scala as a src path on the module
- Set src/test/scala as a test path on the module
- Add scala-library.jar as a library
- Add lib (if it is present) as a jar directory within a module library
- Add lib_managed/compile (if it is present) as a jar directory within a module library
- Add lib_managed/test (if it is present) as a jar directory within a module library
That's it from memory. It would be better if it were automated, but it's no big deal as it is now.
One note of caution: The above approach doesn't work well with new-school sbt, i.e. versions 0.10 and newer, because it doesn't copy dependencies into lib_managed by default. You can add
retrieveManaged := true
to your build.sbt to make it copy the dependencies into lib_managed.
Source: stackoverflow.com
Related Query
- How to create SBT project with IntelliJ Idea?
- How to create sbt project with an android module and run with Intellij ultimate?
- How to create a Play project in IntelliJ IDEA 14 Community Edition?
- How to install library with SBT libraryDependencies in an Intellij project
- How to create an SBT Run configuration in IntelliJ IDEA 11 Community Edition?
- How to create a generic SBT root project with varying sub projects
- How to create Spark/Scala project in IntelliJ IDEA (fails to resolve dependencies in build.sbt)?
- How to create a new SBT project with LibGDX?
- How to use SBT with Intellij Idea
- How to build Android project with Scala sources in IntelliJ IDEA (Community Edition)?
- How to mute Intellij IDEA after sbt project is imported
- How to run an SBT project in IntelliJ Idea 2016.2.4?
- How to create a Scala executable jar file that is built with Maven, and has log4j included, using IntelliJ IDEA IDE
- sbt version and scala version. project configuration for intellij idea with sbt-idea plugin
- How can I use scala sources from a different location in a sbt project and also make it work with IntelliJ IDEA?
- how to create a new play project with sbt
- How to manage multiple interdependent modules with SBT and IntelliJ IDEA?
- How to add Jar libraries to an IntelliJ Idea SBT Scala project?
- How do I change intellij idea to compile with scala 2.11?
- Scala Compiler not found in Intellij IDEA 11 with Play 2.0 project
- IntelliJ IDEA 13: new Scala SBT project hasn't src directory structure generated
- IntelliJ 14 - Create / Import a Scala / SBT project
- How to debug/run a single gatling simulation in IntelliJ IDEA without sbt command?
- How to get rid of scalac ServerException with IntelliJ Idea
- How to get Scala imports working in IntelliJ IDEA with the Play framework?
- Why it took so long to download sbt dependencies when I create a scala project in intellij idea?
- How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
- How to run tests on every code change in IntelliJ IDEA from Scala sbt project?
- How to know if a Scala file modified with IntelliJ Idea is saved and if it is checked into CVS?
- How to setup sbt/scala/play multi-module project which will work fine with Intellij scala plugin
More Query from same tag
- How to turn on Logging in Akka for Scala?
- IntelliJ and Play framework: " `scala-library` has broken sources path"
- Implicit parameters of anonymous functions in Scala
- Transform dataset with empty data for dates
- Scala: using a string argument with an implicit expecting string context
- Is it possible to mock / stub methods of the same test class with ScalaMock?
- Intersection function for Integer Set
- How to make recursive calls within Behaviors.receive?
- How to Make a Scala databricks Notebook on Spark Run Faster, More Performant
- What is the implicit resolution chain of `<:<`
- Ungrouping the grouped table in Scala
- Error in accessing tweets --> "Please use V2 filtered and sample volume stream as alternatives - Spark Scala
- How can I obtain Function objects from methods in Scala?
- Saving type information of datastructures
- Spark - How to calculate percentiles in Spark?
- Defining `implicit def` w/ Implicit?
- Scala json validator a string that contain URI
- How to stack ReaderT and WriterT transformers in scalaz?
- Riak-Java cannot deserialize domain objects from MapReduce query in Scala?
- Faster permutation generator
- Scala split string by group x
- update the last element of List
- Spark Streaming Sliding Window max and min
- Adding XML element with Scala's XML Support
- XOM analogue for Scala?
- IntelliJ: “Output exceeds cutoff limit” in scala worksheet
- Whats the error in below code ? not getting expected output
- Difference between higher-kinded type members declaration
- Secure Social connect provider
- Identify that an Any is actually a scala enumeration value