How to create Scala applications in Sublime Text 3?

I would like to be able to create Scala applications in Sublime Text 3 on Mac 10.9.3. I have Scala 2.11.1 and sbt 0.13.5, and they all work fine. I installed them homegrown.

However, I cannot find how to create a build system for Scala projects. For example, this does not work:

{ "cmd": ["sbt", "test"], "selector": "source.scala", "working_dir": "${project_path}" } 

I found a couple of different ones, but they didn't work for me either. Your thoughts?

UPDATE

 [Errno 2] No such file or directory: 'sbt' [cmd: ['sbt', 'test']] [dir: /Users/alex/Documents/projects/scala/dir1] [path: /usr/bin:/bin:/usr/sbin:/sbin] [Finished] 

UPDATE2:

 { "cmd": ["/usr/local/bin/sbt", "test"], "selector": "source.scala", "working_dir": "${project_path}" } 

Application:

 class MainTest extends App { println("Hellowa!") } 

Output:

  [0m[[0minfo[0m] [0mSet current project to scala (in build file:/Users/alex/Documents/projects/scala/)[0m [0m[[0minfo[0m] [0mCompiling 1 Scala source to /Users/alex/Documents/projects/scala/target/scala-2.10/classes...[0m [0m[[32msuccess[0m] [0mTotal time: 4 s, completed Jun 16, 2014 4:51:38 PM[0m [Finished in 7.2s] 
+6
source share
5 answers

Homebrew installs executables in /usr/local/bin , but the error text that you now provide shows that this directory is not in your path.

Two ways to fix it:

1) Change "cmd": ["sbt", "test"], to "cmd": ["/usr/local/bin/sbt", "test"],

2) Add /usr/local/bin to the PATH environment variable. Note that you will need to do this so that GUI applications such as Sublime Text notice the change; see, for example, Setting environment variables in OS X? for details

+3
source

Perhaps SublimeSBT that "Scala integration of the SBT build tool for Sublime Text 2 and Sublime Text 3." to be a solution?

+3
source

Personally, I use SublimeREPL that supports SBT. SublimeREPL allows you to run SBT from Sublime. This did not allow me to download another package because I already used SublimeSBT for python. I need a minimal configuration for scala code because my IDE had to slow down. At first I try to use my build system, but end up using SBT. SBT offers great advantages over other ways to build your project.

At first, it only compiles the files it needs (those who have been modified and those who depend on them). Secondly, it is very convenient for importing a library. One line in the build.sbt file allows you to import the library from github (usually this line is explained on the github main page). And thirdly, you can compile each entry with the command "~ compile" or "~; compile; runMain" mainclass "

I find the later version to be quite useful since it is often compiled with scala. I often start adding a simple function, save, and when compiling, I improve my first draw.

The main limitation is that you must put your code in src / main / scala or src / main / java if you also have Java files and you need to open the entire root directory with a sublime.

+1
source

Why don't you: D I've been using SublimeSBT for some time, and the only difficulty it calls cmd+shift+p with then sbt start continuous testing . I would advise you to try SBTSublime before baking your own build system.

+1
source

Only Windows! If you have already added the bin folder to the PATH variable:

 { "cmd": ["sbt.bat", "test"], "selector": "source.scala", "working_dir": "${project_path}" } 
0
source

Source: https://habr.com/ru/post/970867/


All Articles