Advertisement
Guest User

build.sbt

a guest
Jun 17th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.68 KB | None | 0 0
  1. import com.github.retronym.SbtOneJar._
  2. import sbt.Keys._
  3.  
  4. import scala.reflect.io
  5.  
  6. def `app.Name` = "Gr8Proj"
  7.  
  8. def `version.major` = 0
  9.  
  10. def `version.minor` = 0
  11.  
  12. def buildNumber = 100500
  13.  
  14. def `app.version` = `version.major` + "." + `version.minor` + "." + buildNumber
  15.  
  16. def finalName = `app.Name` + "-" + `app.version` + ".jar"
  17.  
  18. name := `app.Name`
  19.  
  20. version := `app.version`
  21.  
  22. scalaVersion := "2.11.0"
  23.  
  24. // disable using the Scala version in output paths and artifacts
  25. crossPaths := false
  26.  
  27. oneJarSettings
  28.  
  29. artifactName in oneJar := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact)
  30.                             => "_release/" + finalName }
  31.  
  32. def copyExternalResourcesTask = Def.task {
  33.     val srcExternalResources = baseDirectory.value / "src/main/external-resources"
  34.     val destExternalResources = crossTarget.value / "_release"
  35.     IO.copyDirectory(srcExternalResources, destExternalResources)
  36.     //perform some ad-hoc filtering (walk through output directory recursively)
  37.     //TODO: revisit replacement part, appears to be slow
  38.     io.Directory(destExternalResources) walkFilter { p =>
  39.         !p.isDirectory && !p.name.endsWith(".jar") && !p.name.endsWith(".zip")
  40.     } foreach (p => mapFile(p.toFile, _.replaceAllLiterally("${finalName}", finalName)))
  41. }
  42.  
  43. oneJar <<= oneJar dependsOn copyExternalResourcesTask
  44.  
  45. libraryDependencies ++= Seq(
  46.   "org.springframework.scala" % "spring-scala_2.10" % "1.0.0.RC1",
  47.   "com.typesafe" % "config" % "1.2.1"
  48. )
  49.  
  50. resolvers ++= Seq(
  51.   "spring scala milestones" at "http://repo.springsource.org/milestone"
  52. )
  53.  
  54. def mapFile(file: io.File, replace: String => String) {
  55.   file.printlnAll(file.lines.toList map replace: _*)
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement