Internal Resources
All tools below are installed on the Linux machines of the DIVMS labs. To use those installations, you need first to log in to a lab machine. You can do that either
- directly, by using one of the linux desktops in 301MLH, or
-
remotely from any computer connected to the internet
and running the NoMachine client
(see the CSG Linux help pages for the latter).
Scala
UML
- Violet diagram editor
Scala Interpreter
Working with the Scala interpreter on the CS Linux machines
-
Open a terminal, for instance by selecting Applications|System Tools|Terminal from the top menu of the Gnome Desktop.
-
At the terminal's prompt enter:
scala -
You can now interact with the interpreter by entering any Scala code you wish.
The scala compiler is also available scalac at the terminal. However, ScalaEdit is a more convenient tool for developing and compiling Scala projects.
Simple Build Tool
This application will be most useful for the class projects. You will not need it for simple homework assignments.Creating a simple project with SBT
-
First create a base directory to store the contents of your project,
for example <base-dir>.
-
Add all source files you wish to include in your project to the directory
<base-dir>/src/main/scala.
-
In <base-dir> create a file called build.sbt.
This file will contain build settings for your project.
- Edit build.sbt in your preferred text editor.
A build.sbt file is a set of key-value pairs describing various configurations of your project. Values are associated with a given key in the build.sbt file using the following syntax key := value .
Typically three key-value pairs are always defined in build.sbt:
- name,
the name of you project;
- version, the version of your project; and
- scalaVersion, the version of Scala to be used with your project.
- version, the version of your project; and
name := "Hello" version := "0.1" scalaVersion := "2.9.1"
SBT also allows users to indicate library dependencies for their project. These dependencies can be defined by adding the following in build.sbt:
libraryDependencies += <groupId> % <artifactID> % <revision>Note that the operator += appends a library to the previous value of the libraryDependencies attribute (where := would replace the previous value).
Check the External Resources section for more information of how to set up build.sbt.
Working with SBT on the CS Linux machines
-
Open a terminal, for instance by selecting Applications|System Tools|Terminal from the top menu of the Gnome Desktop.
-
At the terminal's prompt change to your sbt project directory, for example:
cd <project-name> -
At the terminal's prompt enter:
/group/class/c_022/sbt -
Running sbt like this will start it in interactive mode.
SBT Interactive mode
When using SBT in interactive mode users are presented with a command prompt where they can enter a variety commands. The most useful commands for the purposes of this class are:
- compile
- Compiles the main sources of your project.
- run
- Runs the main class of the project.
- test
- Runs any tests defined in the subdirectory src/test/scala/ of your project.
For convenience sbt also allows commands to be automatically rerun whenever a source file of the project is modified. This is done by prefixing a given command with ~. For example,
~ compilewill watch for changes in source files and automatically recompile them accordingly.
If you use ScalaEdit, a more convenient way to use SBT is from within ScalaEdit. (see below).
ScalaEdit
ScalaEdit is a simple IDE for Scala that provides source creation and editing functionalities, syntax highlighting, compilation and testing via an integration with SBT.Working with ScalaEdit on the CS Linux machines
-
Open a terminal, for instance by selecting Applications|System Tools|Terminal from the top menu of the Gnome Desktop.
-
At the terminal's prompt enter:
/group/class/c_022/scalaedit
ScalaEdit maintains at all time a root directory for a Scala project. The root can be (re)set by selecting Project|Change Root... from ScalaEdit's top menu.
Using the Scala interpreter within ScalaEdit
It is possible to open one or more terminals inside ScalaEdit running the Scala interpreter. Jus select Terminal|New Scala Terminal from ScalaEdit's top menu.
Using SBT within ScalaEdit
ScalaEdit has some integration with SBT. It allows you to open one or more SBT terminals internally by selecting Terminal|SBT Terminal|Version 0.11 from its top menu.
When you open an SBT terminal, SBT will be set up automatically to use the current ScalaEdit project root. If you change the project root in ScalaEdit, however, you must open a new SBT terminal to work on that project.
If running compile in an internal SBT terminal produces errors, ScalaEdit will present them in an adjacent window. Clicking on an error in that window will move the cursor in the text edit window to the error's location in the source file (as seen in this screen shot).
Violet
Working with the Violet UML editor on the CS Lab machines
-
Open a terminal, for instance by selecting Applications|System Tools|Terminal from the top menu of the Gnome Desktop.
-
At the terminal's prompt enter:
/group/class/c_022/violet