Storage Layer 2

In this post, we cover the first steps in setting up the project for our comment system storage layer. I’ve decided to use gradle as the build tool. I ran into gradle recently when looking at some other tech, and decided to check it out. I’ve used sbt for projects in the past. There are some things that I really like about sbt - mainly the ability to drop into a console (with or without your project + dependencies in scope) and test out code. That really speeds up development for me in a lot of cases, especially when trying something clever with Scala’s amazing collections framework. On the other hand, the syntax is really heavy on overloaded operators and can turn a project definition into a wall of hieroglyphs that everyone is scared to touch. Gradle has support in its Scala plugin for dropping into a REPL as well!

With all that said, let’s get this gradle project setup!

Gradle Setup

This first thing we need to do is install gradle. Check out the gradle installation page for specific details. Be sure to install at least version 1.4 (required by the latest Akka version).

With gradle installed and in the path, I’ll set up a build script. This is lifted directly from the Akka website, just changing 2.2-SNAPSHOT to 2.2-M3:

apply plugin: 'scala'

repositories {

dependencies {
  compile 'org.scala-lang:scala-library:2.10.1'

tasks.withType(ScalaCompile) {
  scalaCompileOptions.useAnt = false

dependencies {
  compile group: 'com.typesafe.akka', name: 'akka-actor_2.10', version: '2.2-M3'
  compile group: 'org.scala-lang', name: 'scala-library', version: '2.10.1'

The Scala Plugin for gradle has a lot of options that can be tweaked, so feel free to hop over and take a look at them.

One other change worth making is to define our main class so we can test things from gradle directly. This is done with the ‘application’ plugin. Just add the following lines to build.gradle:

apply plugin: 'application'
mainClassName = ""

I couldn’t think of a good name for this comment system project, so I’m just going with Turkey for now… haha.

Initial commit

With the gradle build script in place, I’ve written a typical Hello World class to verify that the Akka dependencies are all in place. You can clone the repo here.

To run it, use gradle run and you should see something similar to the following:

machine:turkey.git dahlgren$ gradle run
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
> Building > :run

Once ‘Hellloooooo’ has been printed, use CTRL-C to kill the application.