Skip to main content

Posts

Showing posts from May, 2014

Integrating code coverage tool JaCoCo in your play 2.1.x project

I've been looking into code coverage for Play 2.1.x and found that the only good option is Jacoco. Its always good to have a fine test coverage in any project. I am working on Play framework & this time i’ve tried to integrate the JaCoCo with my play java project & it’s cool to have it in my project. There are few easy steps to integrate the JaCoCo in Play project. 1. Add the following lines of code in your plugin.sbt file. You’ve to add the plugin dependency to your project’s plugins.sbt. libraryDependencies ++= Seq(   "org.jacoco" % "org.jacoco.core" % "0.5.9.201207300726" artifacts(Artifact("org.jacoco.core", "jar", "jar")),   "org.jacoco" % "org.jacoco.report" % "0.5.9.201207300726" artifacts(Artifact("org.jacoco.report", "jar", "jar"))) addSbtPlugin("de.johoop" % "jacoco4sbt" % "1.2.4") 2. Have

Using the Play console

Launching the console The Play 2.0 console is a development console based on sbt that allows you to manage a Play application’s complete development cycle. To launch the console, enter any existing Play application directory and run the play script: $ cd / path / to / any / application $ play          Getting help Use the help play command to get basic help about the available commands: [ My first application ] $ help play   Running the server in development mode To run the current application in development mode, use the run command: [ My first application ] $ run In this mode, the server will be launched with the auto-reload feature enabled, meaning that for each request Play will check your project and recompile required sources. If needed the application will restart automatically. If there are any compilation errors you will see the result of the compilation directly in your browser: To stop the server, type Crtl+D key, a

Play Framework: Setting up your preferred IDE

Working with Play is easy. You don’t even need a sophisticated IDE, because Play compiles and refreshes the modifications you make to your source files automatically, so you can easily work using a simple text editor. However, using a modern Java or Scala IDE provides cool productivity features like auto-completion, on-the-fly compilation, assisted refactoring and debugging. Eclipse Generate configuration Play provides a command to simplify Eclipse configuration. To transform a Play application into a working Eclipse project, use the eclipse command: without the source jars: [ My first application ] $ eclipse   if you want to grab the available source jars (this will take longer and it’s possible a few sources might be missing): [ My first application ] $ eclipse with - source = true     IntelliJ Generate configuration Play provides a command to simplify Intellij IDEA configuration. To transform a Play application into a working IDEA module, use the

Play Framework: How to create a new play application

Creating a Play application is pretty easy and fully managed by the Play command line utility. This encourages a standard project layout across all Play applications. Open a new command line and enter: $ play new myProject       The play new myProject command creates a new directory  myProject / and populates it with a series of files and directories. The most important are as follows. app/ contains the application’s core, split between models, controllers and views directories. This is the directory where .java source files live. conf/ contains all the application’s configuration files, especially the main application.conf file, the routes definition files and the messages files used for internationalization. project/ contains the build scripts. The build system is based on sbt. But a new play application comes with a default build script that will just work fine for our application. public/ contains all the publicly available resources, which includes Ja

How to install play framework

Prerequisites To run the Play framework, you need JDK 6 or later . If you are using MacOS, Java is built-in. If you are using Linux, make sure to use either the Sun JDK or OpenJDK (and not gcj, which is the default Java command on many Linux distros). If you are using Windows, just download and install the latest JDK package. Note, Java 7 pre update 9 on MacOS has a bug that causes problems with futures and iteratees, including making large file uploads hang. If using Java 7 on MacOS, make sure you are using the latest version. Be sure to have the java and javac commands in the current path (you can check this by typing java -version and javac -version at the shell prompt). Download the binary package Download the latest Play standalone distribution and extract the archive to a location where you have both read and write access. (Running play writes some files to directories within the archive, so don’t install to /opt , /usr/local or anywhere else you’d need s