Create a gist now

Instantly share code, notes, and snippets.

Setting up Play 2.0 in build.gradle
apply plugin: 'java'
apply plugin: 'scala'
// For those using Eclipse or IntelliJ IDEA
apply plugin: 'eclipse'
apply plugin: 'idea'
def findPlay20(){
def pathEnvName = ['PATH', 'Path'].find{ System.getenv()[it] != null }
for(path in System.getenv()[pathEnvName].split(File.pathSeparator)){
for(playExec in ['play.bat', '', 'play']){
if(new File(path, playExec).exists()){
project.ext.playHome = path
project.ext.playExec = new File(path, playExec)
throw new RuntimeException("""'play' command was not found in PATH.
Make sure you have Play Framework 2.0 installed and in your path""")
// Play framework manages its own dependencies in a local Ivy repo
def repoDir = "${playHome}/repository/local/"
url repoDir
ivyPattern "${repoDir}/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
artifactPattern "${repoDir}/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"
layout 'pattern'
//Configuration containing sbt generated .class files
//This is needed for IDEs, because they cannot compile
//play templates by themselves.
//Libraries needed at compilation time but not to be
//exported as part of the distribution
// User defined libraries (will be copied to lib/ before `play compile`)
compile 'group:name:0.1'
// Default Gradle Scala plugin settings below (see Scala plugin page for up-to-date info)
// Libraries needed to run the scala tools
scalaTools 'org.scala-lang:scala-compiler:2.9.1'
scalaTools 'org.scala-lang:scala-library:2.9.1'
// Libraries needed for scala API
provided 'org.scala-lang:scala-library:2.9.1'
// Play 2.0 Framework public API
provided group: 'play', name: 'play_2.9.1', version: '2.0', configuration: 'compile'
playManaged files('target/scala-2.9.1/classes_managed')
task copyPlayLibs(type: Copy){
from configurations.compile
into 'lib'
task "playCompile" (type: Exec, dependsOn: copyPlayLibs) {
commandLine playExec, 'compile'
task "playClean" (type: Exec) {
commandLine playExec, 'clean'
java.srcDir 'app'
compileClasspath += configurations.provided
// optional: if using 'idea' plugin
idea {
module{ += configurations.playManaged += configurations.provided
// optional: if using 'eclipse' plugin
eclipse {
classpath {
plusConfigurations += configurations.playManaged
plusConfigurations += configurations.provided

cool, extactly this i have been looking for! thanks a lot


Mister devprof was faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment