Skip to content

Instantly share code, notes, and snippets.

@jeffbean
Forked from rodionmoiseev/gist:2484934
Last active August 29, 2015 14:02
Show Gist options
  • Save jeffbean/8c14b23de43a63ae9881 to your computer and use it in GitHub Desktop.
Save jeffbean/8c14b23de43a63ae9881 to your computer and use it in GitHub Desktop.
apply plugin: 'java'
apply plugin: 'scala'
// For those using 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 ['activator.bat', 'activator.sh', 'activator']) {
if (new File(path, playExec).exists()) {
project.ext.playHome = path
project.ext.playExec = new File(path, playExec)
return
}
}
}
throw new RuntimeException("""'activator' command was not found in PATH.
Make sure you have Play Framework 2.3 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`)
// 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.11.1'
scalaTools 'org.scala-lang:scala-library:2.11.1'
// Libraries needed for scala API
provided 'org.scala-lang:scala-library:2.11.1'
// Play 2.0 Framework public API
provided group: 'play', name: 'play_2.11.1', version: '2.3', 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