pyc-website
main website for pyc inc.
git clone https://9o.is/git/pyc-website.git
BuildSettings.scala
(4707B)
1 import sbt._
2 import sbt.Keys._
3
4 import com.earldouglas.xsbtwebplugin.WebPlugin.{container, webSettings}
5 import com.earldouglas.xsbtwebplugin.PluginKeys._
6 import sbtbuildinfo.Plugin._
7 import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
8 import ohnosequences.sbt.SbtS3Resolver._
9
10 object BuildSettings {
11 object Ver {
12 val lift = "3.0-M1"
13 val lift_edition = "3.0"
14 val jetty = "9.1.4.v20140401"
15 }
16
17 // call grunt init - requires npm be installed
18 val gruntInit = TaskKey[Int]("grunt-init", "Initialize project for grunt")
19 def gruntInitTask = (baseDirectory in Compile) map { dir =>
20 Process(Seq("npm", "install"), dir) !
21 }
22
23 // call grunt default
24 val gruntDefault = TaskKey[Int]("grunt-default", "Call the grunt default command")
25 def gruntDefaultTask = (baseDirectory in Compile, streams) map { (dir, s) =>
26 val code: Int = Process(Seq("grunt", "default"), dir) ! s.log
27 s.log.info("grunt-init: "+code.toString)
28 if (code != 0) {
29 sys.error("grunt-init failed.")
30 }
31 code
32 }
33
34 // call grunt build
35 val gruntBuild = TaskKey[Int]("grunt-build", "Call the grunt build command")
36 def gruntBuildTask = (baseDirectory in Compile) map { dir =>
37 Process(Seq("grunt", "build"), dir) !
38 }
39
40 // call grunt test
41 val gruntTest = TaskKey[Int]("grunt-test", "Call the grunt test command")
42 def gruntTestTask = (baseDirectory in Compile) map { dir =>
43 Process(Seq("grunt", "test"), dir) !
44 }
45
46 val buildTime = SettingKey[String]("build-time")
47
48 val basicSettings = Defaults.defaultSettings ++ Seq(
49 name := "website",
50 version := "1.4",
51 organization := "inc.pyc",
52 scalaVersion := "2.10.3",
53 scalacOptions <<= scalaVersion map { sv: String =>
54 if (sv.startsWith("2.10."))
55 Seq("-deprecation", "-unchecked", "-feature", "-language:postfixOps", "-language:implicitConversions")
56 else
57 Seq("-deprecation", "-unchecked")
58 },
59 resolvers ++= Seq[Resolver](
60 "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases",
61 "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
62 "tuhlmann" at "https://bitbucket.org/agynamix/mvn-repo/raw/master/snapshots/",
63 s3resolver.value("PYC Releases", s3("releases-pyc-inc")),
64 s3resolver.value("PYC Snapshots", s3("snapshots-pyc-inc"))
65 )
66 )
67
68 val gruntSettings = Seq(
69 gruntInit <<= gruntInitTask,
70 gruntDefault <<= gruntDefaultTask,
71 gruntBuild <<= gruntBuildTask,
72 gruntTest <<= gruntTestTask
73 )
74
75 val liftAppSettings =
76 basicSettings ++
77 gruntSettings ++
78 webSettings ++
79 S3Resolver.defaults ++
80 buildInfoSettings ++
81 seq(
82 buildTime := System.currentTimeMillis.toString,
83
84 // build-info
85 buildInfoKeys ++= Seq[BuildInfoKey](buildTime),
86 buildInfoPackage := "inc.pyc",
87 sourceGenerators in Compile <+= buildInfo,
88
89 // eclipse
90 EclipseKeys.withSource := true,
91
92 // dependencies
93 //compile in Compile <<= (compile in Compile) dependsOn gruntBuild,
94 // (start in container.Configuration) <<= (start in container.Configuration) dependsOn gruntBuild,
95 Keys.`package` <<= (Keys.`package` in Compile) dependsOn gruntDefault,
96 test in Test <<= (test in Test) dependsOn gruntTest,
97
98 // add javascript and css source files to the webapp, for development
99 (webappResources in Compile) <+= (target in Compile) { _ / "grunt" / "build" / "css" },
100
101 // add grunt generated resources to the classpath
102 (unmanagedResourceDirectories in Compile) <+=
103 (target in Compile) { _ / "grunt" / "resources" },
104
105 // massage the war
106 (warPostProcess in Compile) <<= (target in Compile) map { tgt =>
107 val webapp = tgt / "webapp"
108 val gdist = tgt / "grunt" / "dist"
109 () => {
110 // remove the frontend sources
111 val files = Seq(webapp / "app", webapp / "assets", webapp / "less", webapp / "vendor")
112 IO.delete(files)
113 // copy the minified assets
114 IO.copyDirectory(gdist, webapp)
115 }
116 },
117
118 publishMavenStyle := true,
119 publishArtifact in Test := false,
120 pomIncludeRepository := { _ => false },
121 publishTo := Some(s3resolver.value(
122 "My "+{if (isSnapshot.value) "snapshots-pyc-inc" else "releases-pyc-inc"}+" S3 bucket",
123 s3(if (isSnapshot.value) "snapshots-pyc-inc" else "releases-pyc-inc"))),
124
125 s3credentials := {
126 Path.userHome / ".ivy2" / ".s3credentials"
127 },
128
129 s3region := com.amazonaws.services.s3.model.Region.US_Standard
130 )
131
132 lazy val noPublishing = seq(
133 publish := (),
134 publishLocal := ()
135 )
136 }
137