I've been working with Play2 Framework for several years now and it's a very nice way to develop in Scala. Some of the Play projects have grown rather large and have become sluggish in combination with SBT. Resolving dependencies, compiling and starting Play all take a long time with SBT. Perhaps my biggest objection is that SBT can not stage a self-contained integration-test environment. These shortcomings have forced me to look at SBT alternatives. I arrived at a way to build and run Play projects with support for auto-reloading using Maven, play2-maven-plugin, sbt-compiler-maven-plugin, Eclipse, DCEVM and Zinc. This article describes how to set up such an environment for your own enjoyment.
Start by downloading the following tools:
- Java SE Development Kit 7u51 - needs registration at Oracle (which is unfortunate but free)
- DCEVM (full) for Java 7u51 (build 3) - make sure to get the full version and not the light version
- Scala IDE for Eclipse - I used version Scala IDE 4.0.0 and Eclipse 4.4 Luna
- Zinc latest version - I used Zinc 0.3.7
- Apache Maven latest version - I used Maven 3.2.3
Which version of Scala IDE, Eclipse, Zinc or Maven you install should not matter much. However, the Java and DCEVM versions do matter. It is paramount that the build versions of both Java and DCEVM (in this case 7u51) match perfectly and that you get a full version of DCEVM.
Make sure that Java 7u51 is your default Java version. You can verify this by running `java -version` from the command line. Also make sure DCEVM is correctly patched into the JVM as an alternative JVM, which can be verified by running `java -XXaltjvm=dcevm -version`, which should show something like:
I imagine this will also work with other IDEs that have hotswapping support, like Netbrains IntelliJ IDEA, but I have not tried others so far. If you have tried, please drop your experience in the comments below. Grzegorz Slowikowski, the author of play2-maven-plugin, has brought to my attention that LinkedIn is planning to bring hot-reload support for Play 2 to Gradle. Somewhere in the future the play2-maven-plugin will support hot-reloading natively as well, until that time it will remain in beta. Simpler and more portable alternatives to SBT are on the way, stay tuned. Thanks for reading.