Tutorial: Create an AutoMan Project

Once you have Java, Scala, and sbt installed (if you don't go back to Installing Prerequisites), you can create an AutoMan project. Note that these instructions assume that you are familiar with the command line on a UNIX machine. You can run AutoMan in other operating systems, like Windows, but you will need to adapt the instructions below.

Create a project folder

We're going to start by creating a new directory for our project. This will create a new directory in our current location.

$ mkdir my-first-automan-project

Now go ahead and cd into that directory.

$ cd my-first-automan-project

In any sbt project, there are two primary components:

  • build.sbt: Is a build specification, where you will configure your library dependencies, among other things.

  • src: Is a directory where you will store your application code.

build.sbt

Let's start by creating a build.sbt file. I am going to do this with emacs build.sbt but you can use any text editor with which you are comfortable. Paste the following into your build.sbt file:

scalaVersion := "2.12.12"
name := "my-first-automan-app"
version := "1.0"
libraryDependencies += "org.automanlang" %% "automan" % "1.4.2"

Most of this should be self-explanatory, but I will explain anyway. Note that you must use the := assignment operator and not = in build.sbt files.

  • scalaVersion: The version of Scala you want to use. I have specified the latest version of Scala 2.12 at the time of this writing. If you don't have this precise version of Scala on your machine, don't worry,sbt will install it for you. Note that AutoMan does not currently support Scala 2.13.

  • name: The name of your application.

  • version: The version of your application. This won't be all that important for this example, but if you ever decide to publish your app, this number will be used as a part of your app's metadata.

  • libraryDependencies: This is where we specify that our app depends on one or more third-party libraries. I have pre-filled this entry with the dependency information for the latest version of AutoMan. sbt will automatically download and install whatever dependencies you specify. Observe that we use += for libraryDependencies; this is because libraryDependencies is a list. += adds a dependency to that list.

You can find more libraries at MVNrepository. For example, here is the MVNrepository page for AutoMan. Note the "SBT" tab which includes the line we pasted into our build.sbt file above. You can include any third-party library you find in MVNrepository, with some small caveats, most notably that some libraries are tied to specific versions of Scala. Just add another libraryDependencies line using +=.

src/main/scala and source files

Let's now create our src directory. sbt saves you configuration work by being rather picky about where you store your source code. Let's create that location:

$ mkdir -p src/main/scala

And let's create a new Scala file in that folder (again, use your favorite text editor):

$ emacs src/main/scala/MyFirstAutoManApp.scala

Once you have a new, blank MyFirstAutoManApp.scala file loaded up in your editor, we can start creating our app.

Last updated