/framework/src/sbt-plugin/src/main/scala/PlaySettings.scala
Scala | 222 lines | 132 code | 85 blank | 5 comment | 7 complexity | 09426bb31d25b452374326b68380be90 MD5 | raw file
- package sbt
- import Keys._
- import PlayKeys._
- trait PlaySettings {
- this: PlayCommands with PlayPositionMapper =>
-
- protected def whichLang(name: String): Seq[Setting[_]] = {
- if (name == JAVA) {
- defaultJavaSettings
- } else if (name == SCALA) {
- defaultScalaSettings
- } else {
- Seq.empty
- }
- }
- lazy val defaultJavaSettings = Seq[Setting[_]](
- templatesImport ++= Seq(
- "models._",
- "controllers._",
- "java.lang._",
- "java.util._",
- "scala.collection.JavaConversions._",
- "scala.collection.JavaConverters._",
- "play.api.i18n._",
- "play.core.j.PlayMagicForJava._",
- "play.mvc._",
- "play.data._",
- "play.api.data.Field",
- "play.mvc.Http.Context.Implicit._",
- "views.%format%._"),
- routesImport ++= Seq(
- "play.libs.F"
- ),
- ebeanEnabled := true
- )
- lazy val defaultScalaSettings = Seq[Setting[_]](
- templatesImport ++= Seq(
- "models._",
- "controllers._",
- "play.api.i18n._",
- "play.api.mvc._",
- "play.api.data._",
- "views.%format%._"))
- def closureCompilerSettings(optionCompilerOptions: com.google.javascript.jscomp.CompilerOptions) = Seq[Setting[_]](
- resourceGenerators in Compile <<= JavascriptCompiler(Some(optionCompilerOptions))(Seq(_)),
- resourceGenerators in Compile <+= LessCompiler,
- resourceGenerators in Compile <+= CoffeescriptCompiler
- )
- lazy val defaultSettings = Seq[Setting[_]](
- scalaVersion := play.core.PlayVersion.scalaVersion,
- playPlugin := false,
- resolvers ++= Seq(
- "Typesafe Releases Repository" at "http://repo.typesafe.com/typesafe/releases/",
- "Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/"
- ),
- target <<= baseDirectory / "target",
- sourceDirectory in Compile <<= baseDirectory / "app",
- sourceDirectory in Test <<= baseDirectory / "test",
- confDirectory <<= baseDirectory / "conf",
- resourceDirectory in Compile <<= baseDirectory / "conf",
- scalaSource in Compile <<= baseDirectory / "app",
- scalaSource in Test <<= baseDirectory / "test",
- javaSource in Compile <<= baseDirectory / "app",
- javaSource in Test <<= baseDirectory / "test",
- distDirectory <<= baseDirectory / "dist",
- distExcludes := Seq.empty,
- libraryDependencies <+= (playPlugin) { isPlugin =>
- val d = "play" %% "play" % play.core.PlayVersion.current
- if(isPlugin)
- d % "provided"
- else
- d
- },
- libraryDependencies += "play" %% "play-test" % play.core.PlayVersion.current % "test",
- parallelExecution in Test := false,
- fork in Test := true,
- testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "sequential", "true"),
- testOptions in Test += Tests.Argument(TestFrameworks.JUnit, "junitxml", "console"),
- testListeners <<= (target, streams).map((t, s) => Seq(new eu.henkelmann.sbt.JUnitXmlTestsListener(t.getAbsolutePath, s.log))),
- testResultReporter <<= testResultReporterTask,
- testResultReporterReset <<= testResultReporterResetTask,
- sourceGenerators in Compile <+= (state, confDirectory, sourceManaged in Compile, routesImport) map RouteFiles,
- // Adds config directory's source files to continuous hot reloading
- watchSources <+= confDirectory map { all => all },
- sourceGenerators in Compile <+= (state, sourceDirectory in Compile, sourceManaged in Compile, templatesTypes, templatesImport) map ScalaTemplates,
- // Adds app directory's source files to continuous hot reloading
- watchSources <++= baseDirectory map { path => ((path / "app") ** "*").get },
- commands ++= Seq(shCommand, playCommand, playRunCommand, playStartCommand, h2Command, classpathCommand, licenseCommand, computeDependenciesCommand),
- shellPrompt := playPrompt,
- copyResources in Compile <<= (copyResources in Compile, playCopyAssets) map { (r, pr) => r ++ pr },
- mainClass in (Compile, run) := Some("play.core.server.NettyServer"),
- compile in (Compile) <<= PostCompile(scope = Compile),
- dist <<= distTask,
- computeDependencies <<= computeDependenciesTask,
- playVersion := play.core.PlayVersion.current,
- playCommonClassloader <<= playCommonClassloaderTask,
- playCopyAssets <<= playCopyAssetsTask,
- playCompileEverything <<= playCompileEverythingTask,
- playPackageEverything <<= playPackageEverythingTask,
- playReload <<= playReloadTask,
- playStage <<= playStageTask,
- cleanFiles <+= distDirectory,
- logManager <<= extraLoggers(PlayLogManager.default(playPositionMapper)),
- ivyLoggingLevel := UpdateLogging.DownloadOnly,
- routesImport := Seq.empty[String],
- playMonitoredFiles <<= playMonitoredFilesTask,
- playDefaultPort := 9000,
- playOnStarted := Nil,
- playOnStopped := Nil,
- // Assets
- playAssetsDirectories := Seq.empty[File],
- playExternalAssets := Seq.empty[(File, File => PathFinder, String)],
- playAssetsDirectories <+= baseDirectory / "public",
- requireJs := Nil,
- requireJsFolder := "",
- requireJsShim := "",
- requireNativePath := None,
- buildRequire <<= buildRequireTask,
- packageBin in Compile <<= (packageBin in Compile).dependsOn(buildRequire),
- resourceGenerators in Compile <+= LessCompiler,
- resourceGenerators in Compile <+= CoffeescriptCompiler,
- resourceGenerators in Compile <+= JavascriptCompiler(fullCompilerOptions = None),
- lessEntryPoints <<= (sourceDirectory in Compile)(base => ((base / "assets" ** "*.less") --- base / "assets" ** "_*")),
- coffeescriptEntryPoints <<= (sourceDirectory in Compile)(base => base / "assets" ** "*.coffee"),
- javascriptEntryPoints <<= (sourceDirectory in Compile)(base => ((base / "assets" ** "*.js") --- (base / "assets" ** "_*"))),
- lessOptions := Seq.empty[String],
- coffeescriptOptions := Seq.empty[String],
- closureCompilerOptions := Seq.empty[String],
- // Settings
- devSettings := Nil,
- // Templates
- templatesImport := Seq("play.api.templates._", "play.api.templates.PlayMagic._"),
- templatesTypes := {
- case "html" => ("play.api.templates.Html", "play.api.templates.HtmlFormat")
- case "txt" => ("play.api.templates.Txt", "play.api.templates.TxtFormat")
- case "xml" => ("play.api.templates.Xml", "play.api.templates.XmlFormat")
- })
- }