How to integrate Play Framework 2.0 into Gradle build management using Maven dependencies?

This is a very tricky business. SBT in Play is used for fetching dependencies, compiling source and templates, and for the SBT incremental compilation + auto-reloading feature. I have written a build.gradle script to resolve all Play 2.0 dependencies and set-up Eclipse or IntelliJ IDEA classpaths, and made it public here.

I will try to implement the compilation later when I have time, but that would require some research.
Of course, you can add compile and run tasks that just delegate to SBT but that would require describing all your project dependencies in both SBT and Gradle, which will become difficult to manage.

Edit:

I have updated the sample build.gradle file. I have added playCompile and playClean tasks that should help in a CI environment. The playCompile task does the following:

  1. Copy all user dependencies (defined in compile configuration) to lib/ folder. This works because Play will kindly pick up all jars from under lib/.
  2. Execute play compile command to compile all sources, templates and other Play framework stuff.

You can use cleanCopyPlayLibs and playClean to remove the output of the above commands, respectively.

Note that there appears to be a strange problem (bug?) on Windows, which means that even if play compile fails, gradle will tell you it succeeded.

Reply to comment:

I think you are simply missing

repositories{
  mavenCentral()
}

in your file. Check this doc out.

Leave a Comment