Collect and display drinks added to the directory.
Scala Java
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Whiskey Directory

The goal of this application is to create a way for people in a city to add and talk about drinks they’ve had in the city.



BDD Specs are written with the help of the specs library available on Google Code. The specs are executed as JUnit tests during Maven’s test phase. This means the Maven build outputs information about tests run, passed and failed rather than information about what how the specs are defined. To see the specs executed as JUnit tests execute the `mvn clean test` command from the command prompt.

In order to run the specs as specs first execute `mvn package` which will build the war file and a directory with the war contents. Once the package is built run a command similar to:

	scala -cp target/whiskey-directory/WEB-INF/lib/*:target/classes/:target/test-classes/:$M2_REPOSITORY/org/specs/specs/1.4.3/specs-1.4.3.jar {SpecificationObject}

In the above command {SpecificationObject} is the full path of any object which extends org.specs.Specification, and $M2_REPOSITORY is an environment variable set to the root of the local Maven repository. On OSX $M2_REPOSITORY will probably be ~/.m2/repository but the tilde must be replaced with /Users/username.

With the above guidelines a full command may look like:

	scala -cp target/whiskey-directory/WEB-INF/lib/*:target/classes/:target/test-classes/:$M2_REPOSITORY/org/specs/specs/1.4.3/specs-1.4.3.jar com.whiskeydirectory.model.DrinkSpecs

Building – Ant

AppEngine jars

In order to make the datanucleus class enhancing work the jars of version 1.1.0 in the AppEngine SDK needed to be replaced with the same jars of version 1.1.2 available in datanucleus’ Maven2 repository. The jars are in {sdk.home}/lib/tools/orm/ and {sdk.home}/user/orm/. The only datanucleus jar which should not be replaced is

WARNING: Performing this replacement however makes the data retrieval mechanisms of the AppEngine unusable. Hopefully there is another way to do this.

Ant’s build.xml file looks for an file at the same level as build.xml (project root) and expects the following properties to be defined:

  • sdk.dir – location of the appengine sdk
  • scala.compile.jar – location of the Scala compile jar
  • scala.library.jar – location of the Scala library jar
  • scala.src – top level Scala source directory (.scala files)
  • scala.test – top level Scala test source directory (.scala files)
  • java.src – top level Java source directory (.java files)
  • java.test – top level Java test source directory (.java files)
  • resources.src – top level resource directory (get copied into build.dir)
  • webapp.src – top level webapp directory (files get copied into war.dir)
  • war.dir – top level packaging directory
  • test.jars – JUnit and Specs jars
  • test.dir – where to compile test source to (.class files)
  • build.dir – compile source files to here (.class files)
  • lib.dir – copy library files to here (.jar files)

The build.xml defines several targets, what they do is outlined below:

  • clean – no dependencies – delete the directory specified by war.dir property
  • init – no dependencies – creates the directory specified by war.dir and copies all files in webapp.src into it
  • copyjars – depends on init – copies jar files in sdk.dir/lib/user and scala.library.jar into lib.dir
  • compile – depends on copyjars – compiles scala and java src into build.dir and copies resources.src into build.dir
  • test-compile – depends on compile – compiles java.test and scala.test into test.dir
  • package – depends on compile – runs the enhance_war task defined in sdk.dir/config/user/ant-macros.xml
  • test – depends on test-compile – executes tests compiled in test-compile using JUnit
  • dev – no dependencies – starts the dev_appserver jetty server
  • install – depends on clean, package and test – pushes war to app engine servers

Building – Maven

AppEngine jars

In order to build an Java AppEngine project with Maven (2.0.10) first the jars from the SDK need to be installed in the local repository. To do this first navigate to where the Java AppEngine SDK are located and then run the following four commands.

	mvn install:install-file -Dfile=lib/user/orm/ -DgroupId=org.datanucleus -DartifactId=datanucleus-appengine -Dpackaging=jar -DgeneratePom=true
	mvn install:install-file -Dfile=lib/user/appengine-api-1.0-sdk-1.2.0.jar -DartifactId=appengine-api-1.0-sdk -Dversion=1.2.0 -Dpackaging=jar -DgeneratePom=true
	mvn install:install-file -Dfile=lib/shared/appengine-local-runtime-shared.jar -DartifactId=appengine-local-runtime-shared -Dversion=1.2.0 -Dpackaging=jar -DgeneratePom=true
	mvn install:install-file -Dfile=lib/appengine-tools-api.jar -DartifactId=appengine-tools -Dversion=1.2.0 -Dpackaging=jar -DgeneratePom=true

Scala jars

The Scala jars, including the specs library, should be located by Maven in the declared repositories in the pom.xml.