-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
194 lines (166 loc) · 5.85 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import java.io.Closeable
import scala.concurrent.Await
lazy val `sekyll` = (project in file("."))
.enablePlugins(SbtTwirl, SbtWeb)
scalaVersion := "2.11.7"
//scalacOptions += "-Ylog-classpath"
JsEngineKeys.engineType := JsEngineKeys.EngineType.Node
WebKeys.stagingDirectory := file("docs")
cleanFiles <+= baseDirectory { base => base / "docs" }
libraryDependencies ++= Seq(
/*
"org.webjars" % "normalize.css" % "3.0.2",
"org.webjars" % "foundation" % "6.2.0",
"org.webjars.bower" % "waypoints" % "4.0.0",
"org.webjars" % "prettify" % "4-Mar-2013",
*/
//used in pages
"org.webjars" % "font-awesome" % "4.7.0"
,"org.webjars" % "bootstrap" % "4.0.0-alpha.6-1" //"4.0.0-beta"
,"org.webjars.npm" % "popper.js" % "1.11.1"
,"org.webjars" % "tether" % "1.4.0"
,"org.webjars" % "jquery" % "2.2.1" //3.2.1
,"com.lightbend.markdown" %% "lightbend-markdown-server" % "1.5.2"
,"org.yaml" % "snakeyaml" % "1.12"
)
resolvers += Resolver.bintrayIvyRepo("typesafe", "ivy-releases")
val publicVersion = "0.1"
val assetFingerPrint = publicVersion //"git rev-parse HEAD".!!.trim
val httpServer = AttributeKey[Closeable]("http-server")
val stopCommand = Command.command("stop") { state =>
state.attributes.get(httpServer) match {
case Some(server) =>
server.close()
state.remove(httpServer)
case None => state
}
}
val runCommand = Command.make("run") { state =>
import complete.Parsers._
import complete.Parser
import scala.concurrent.duration._
(Space ~> NatBasic).?.map { maybePort =>
() =>
val port = maybePort.getOrElse(8080)
val log = state.log
val extracted = Project.extract(state)
val stageDir = extracted.get(WebKeys.stagingDirectory)
log.info(s"\u001b[32mRunning HTTP server on http://localhost:$port, press ENTER to exit...\u001b[0m")
val simpleHttpServer = SimpleHTTPServer(stageDir, port)
Await.ready(simpleHttpServer.bindingFuture, 5.seconds)
val stateWithStop = "stop" :: state.put(httpServer, new Closeable {
override def close(): Unit = {
log.info("Shutting down HTTP server")
simpleHttpServer.close()
}
}).addExitHook(() => simpleHttpServer.close())
val extraSettings = Seq(
javaOptions += "-Ddev",
//fork := true // required for javaOptions to take effect
fork := false //needed for debug
)
val stateWithExtraSettings = extracted.append(extraSettings, stateWithStop)
Parser.parse("~web-stage", stateWithExtraSettings.combinedParser) match {
case Right(cmd) => cmd()
case Left(msg) => throw sys.error(s"Invalid command:\n$msg")
}
}
}
val deploySiteCommand = Command.args("deploySite","deploy staged site to master branch") { (state, args) =>
println("start deploy")
/*
//val state2 = Command.process("clean",state)
//val state3 = Command.process("web-stage",state2)
val state3 = state
val remote = "origin"
println(System.getProperty("java.class.path"))
println(System.getenv("CLASSPATH"))
val deployBranch = "master"
println("hi header")
"cmd /c echo hi".!!
println("git")
"cmd /c git status".!!
println("done")
val commands = s"""
git status
"""
echo git init;
echo git add .
echo commit -m "Website build"
# Push the repo to the master branch of the main repo
echo git push ../../.. master:$deployBranch -f
# Push the repo to the website
cd ../../..
echo git push $remote $deployBranch:master -f
"""
println(s"running [$commands]")
commands.!!
state3
*/
state
}
commands ++= Seq(runCommand, stopCommand, deploySiteCommand)
val generateHtml = taskKey[Seq[File]]("Generate the site HTML")
target in generateHtml := WebKeys.webTarget.value / "generated-html"
generateHtml <<= Def.taskDyn {
val outputDir = (target in generateHtml).value
val docsDir = sourceDirectory.value / "docs"
val markdownDir = (sourceDirectory in Compile).value / "markdown"
val blogDir = sourceDirectory.value / "blog"
Def.task {
(runMain in Compile).toTask(Seq(
"eu.dcsi.sekyll.docs.DocumentationGenerator",
outputDir,
docsDir,
markdownDir,
blogDir,
assetFingerPrint
).mkString(" ", " ", "")).value
outputDir.***.filter(_.isFile).get
}
}
def path(segments: String*): String = segments.mkString(java.io.File.separator)
Concat.groups := Seq(
s"css/all-$assetFingerPrint.css" -> group(Seq(
path("lib", "tether", "css", "tether.css"),
path("lib", "bootstrap", "css", "bootstrap.css"),
path("lib", "font-awesome", "css", "font-awesome.css"),
path("css", "main.css"),
path("css", "modern-business.css")
)),
s"js/all-$assetFingerPrint.js" -> group(Seq(
path("lib", "jquery", "jquery.js"),
path("lib", "popper.js", "dist", "umd", "popper.js"),
path("lib", "tether", "js", "tether.js"),
path("lib", "bootstrap", "js", "bootstrap.js"),
path("js", "main.js"),
path("js", "contact_me.js"),
path("js", "jqBootstrapValidation.js")
))
/*
,
s"$assetFingerPrint-all-styles-concat.css" -> group(Seq(
path("lib", "foundation", "dist", "foundation.min.css"),
path("lib", "prettify", "prettify.css"),
"main.min.css"
)),
s"$assetFingerPrint-all-scripts-concat.js" -> group(Seq(
path("lib", "jquery", "jquery.min.js"),
path("lib", "foundation", "dist", "foundation.min.js"),
path("lib", "waypoints", "lib", "jquery.waypoints.min.js"),
path("lib", "waypoints", "lib", "shortcuts", "sticky.min.js"),
path("lib", "prettify", "prettify.js"),
path("lib", "prettify", "lang-scala.js"),
"main.min.js"
))
*/
)
StylusKeys.compress := true
pipelineStages := Seq(uglify, concat)
WebKeys.pipeline ++= {
generateHtml.value pair relativeTo((target in generateHtml).value)
}
watchSources ++= {
((sourceDirectory in Compile).value / "markdown").***.get ++
(sourceDirectory.value / "blog").***.get
}