Skip to content

Instantly share code, notes, and snippets.

@kpmeen
Forked from rodionmoiseev/gist:2484934
Created January 11, 2014 22:53
Show Gist options
  • Save kpmeen/8378091 to your computer and use it in GitHub Desktop.
Save kpmeen/8378091 to your computer and use it in GitHub Desktop.
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.sh', 'play']){
if(new File(path, playExec).exists()){
project.ext.playHome = path
project.ext.playExec = new File(path, playExec)
return
}
}
}
throw new RuntimeException("""'play' command was not found in PATH.
Make sure you have Play Framework 2.0 installed and in your path""")
}
findPlay20()
repositories{
mavenCentral()
// Play framework manages its own dependencies in a local Ivy repo
ivy{
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'
}
}
configurations{
//Configuration containing sbt generated .class files
//This is needed for IDEs, because they cannot compile
//play templates by themselves.
playManaged
//Libraries needed at compilation time but not to be
//exported as part of the distribution
provided
}
dependencies{
// 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'
}
sourceSets.main{
java.srcDir 'app'
compileClasspath += configurations.provided
}
// optional: if using 'idea' plugin
idea {
module{
scopes.COMPILE.plus += configurations.playManaged
scopes.PROVIDED.plus += configurations.provided
}
}
// optional: if using 'eclipse' plugin
eclipse {
classpath {
plusConfigurations += configurations.playManaged
plusConfigurations += configurations.provided
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment