csoma / Scala-starter

An easy way to get started with Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scala-starter

An easy way to get started with Scala.

Overview

This project contains the minimum requirements to get started with Scala. Both command line REPL and compile/run mode are supported.

  • For code changes see src/main/scala/test/Main.scala
  • To add libraries use project/Build.scala

Several libraries are already in the Build file, from database drivers to PDF processing and Akka.

Mac, Windows and Linux build instructions are provided below.

Getting started

Mac

Get Java 1.6 or later

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install SBT:

brew install git sbt

Get these source files:

git clone https://github.com/csoma/Scala-starter.git
cd Scala-starter

Alternative: download as a ZIP

Start the command line REPL

sbt console
println("Hello!")

Ctrl-D will exit

Or run the included "Hello World" app

sbt run

Windows

Linux

  • Ubuntu: apt-get install sbt git
  • RedHat: yum install sbt git
  • Get the sources: git clone https://github.com/csoma/Scala-starter.git
  • Start REPL: sbt console
  • Build and run the app: sbt run

The files

  • src/main/scala/test/Main.scala - a minimal "Hello World" program
  • project/Buid.scala - sets the project name, compiler flags, additional components like Scalatra and Postgres driver. Customize it to your needs.
  • project/build.sbt - adds the "eclipse" command to sbt (sbt plugin)

Enabling additional components

Open the "project/Build.scala" file in the editor, find the "Additional components" section.

To enable a library just remove the comment from that line, like Scalaz, Postgres driver, Apache HttpComponent etc.

SBT will automatically download the specified library version and add it to classpath.

Any component supported by Maven can be added, see the "Component versions" section. The default repo list can be extended with the "ExtraResolvers" variable at the end of the file.

Scala IDE

IntelliJ IDEA

See the following links:

Eclipse

  • Install Eclipse
  • Install Eclipse Scala IDE plugin: http://scala-ide.org/
  • In project/build.sbt enable the Eclipse plugin
  • From command line run "sbt eclipse"
  • Make sure the Scala perspective is selected
  • From Eclipse use "Import Wizard" to import "General/Existing Projects into Workspace"
  • Run now should have "Scala Application"

SBT - build tool

  • sbt help - SBT (build tool) usage help
  • sbt help tasks - available task list: clean, compile, run, package, test etc.
  • sbt console-quick - starts the Scala REPL
  • sbt console - starts the Scala REPL with the active project in the classpath
  • sbt run - runs the active project (in this case just prints "Hello World")
  • sbt eclipse - generate Eclipse project definitions
  • sbt package - creates a JAR file in the "target" folder (size: about 1.5K)
  • sbt - starts the SBT console

Other starter projects

Scala resources

About

An easy way to get started with Scala


Languages

Language:Scala 100.0%