-
-
Save danielnegri/365f6f4d5e06f1aa581f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import sbt.Keys._ | |
import play.Project._ | |
import sbtbuildinfo.Plugin._ | |
import com.gu.SbtJasminePlugin._ | |
object ApplicationBuild extends Build { | |
val appName = "your-app-name" | |
val appVersion = "1.0-SNAPSHOT" | |
/* Scala Code Coverage Tool; to run it from the Play console: | |
* scct:test | |
* | |
* and view the output (with Firefox, due to cross-site issues) at: | |
* file://<project-location>/target/scala-2.10/coverage-report/index.html | |
*/ | |
lazy val scctSettings = Defaults.defaultSettings ++ Seq(ScctPlugin.instrumentSettings : _*) | |
lazy val sysProps = scala.util.Properties | |
// Check first for a -D flag, then an environment variable | |
private def resolveKey(key:String) = { | |
sysProps.propOrElse( key, sysProps.envOrElse(key, "N/A")) | |
} | |
val appDependencies = Seq( | |
// Add your project dependencies here, | |
jdbc, | |
anorm, | |
"org.scalaz" %% "scalaz-core" % "7.0.3", | |
"org.mockito" % "mockito-all" % "1.9.5" | |
) | |
// Only compile the custom bootstrap.less file and any other *.less file in the stylesheets directory | |
def customLessEntryPoints(base: File): PathFinder = ( (base / "app" / "assets" / "stylesheets" / "custom" / "custom.less") +++ (base / "app" / "assets" / "stylesheets" * "*.less") ) | |
val main = play.Project(appName, appVersion, appDependencies, settings = Defaults.defaultSettings ++ buildInfoSettings ++ scctSettings) | |
.settings( | |
testOptions in Test += Tests.Argument("junitxml", "console"), | |
// include 3rd-party javascript libraries | |
unmanagedResources in Compile ++= (file("public/javascripts") ** "*.js").get, | |
sourceGenerators in Compile <+= buildInfo, | |
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion), | |
// Get pertinent build info from Jenkins - these properties are set at build time: | |
// https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-below | |
buildInfoKeys ++= Seq[BuildInfoKey]( | |
"extraInfo" -> resolveKey("EXTRA_INFO"), | |
"jenkinsBuild" -> resolveKey("BUILD_NUMBER"), | |
"buildId" -> resolveKey("BUILD_ID"), | |
"builtBy" -> resolveKey("NODE_NAME"), | |
"gitBranch" -> resolveKey("GIT_BRANCH"), | |
"gitVersion" -> resolveKey("GIT_COMMIT")), | |
buildInfoPackage := "util" | |
) | |
.settings( lessEntryPoints <<= baseDirectory(customLessEntryPoints)) | |
.settings(jasmineSettings : _*) | |
.settings( | |
// jasmine configuration, overridden as we don't follow the default project structure sbt-jasmine expects | |
appJsDir <+= baseDirectory / "target/scala-2.10/resource_managed/main/public/javascripts", | |
appJsLibDir <+= baseDirectory / "public/javascripts", | |
jasmineTestDir <+= baseDirectory / "test/javascripts/", // specs should be in test/js/specs/exampleSpec.js | |
jasmineConfFile <+= baseDirectory / "test/javascripts/test.dependencies.js", | |
// link jasmine to the standard 'sbt test' action. Now when running 'test' jasmine tests will be run | |
// and after that other Play tests will be executed. | |
(test in Test) <<= (test in Test) dependsOn (jasmine), | |
// ensures copy-resources are called (if need updating) before running jasmine task (for coffeescript) | |
(jasmine) <<= (jasmine) dependsOn (copyResources in Compile), | |
// auto watch javascript spec directories | |
unmanagedResources in Test ++= (file("test/javascripts") ** "*.js").get, | |
// adds coffeescript source files recompilation in ~jasmine | |
unmanagedResources in Test ++= (file("app/assets/javascripts") ** "*.coffee").get | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment