-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathbuild.sbt
103 lines (93 loc) · 3.64 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
import sbt.Keys._
import sbt.Project.projectToRef
import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
ThisBuild / scalafmtOnCompile := true
resolvers in ThisBuild += Resolver.jcenterRepo
// a special crossProject for configuring a JS/JVM/shared structure
lazy val shared = (crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file("shared"))
.settings(
version := Settings.version,
scalaVersion := Settings.versions.scala,
libraryDependencies ++= Settings.sharedDependencies.value
)
// set up settings specific to the JS project
.jsConfigure(_ enablePlugins ScalaJSWeb)
lazy val sharedJVM = shared.jvm.settings(name := "sharedJVM")
lazy val sharedJS = shared.js.settings(name := "sharedJS")
// instantiate the JS project for SBT with some additional settings
lazy val client = (project in file("client"))
.settings(
name := "client",
version := Settings.version,
scalaVersion := Settings.versions.scala,
scalacOptions ++= Settings.scalacOptions,
libraryDependencies ++= Settings.sharedDependencies.value ++ Settings.scalajsDependencies.value,
jsDependencies ++= Settings.jsDependencies.value,
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv(),
// yes, we want to package JS dependencies
skip in packageJSDependencies := false,
// use Scala.js provided launcher code to start the client app
scalaJSUseMainModuleInitializer := true
)
.enablePlugins(ScalaJSPlugin, ScalaJSWeb)
.dependsOn(sharedJS)
// Client projects (just one in this case)
lazy val clients = Seq(client)
// instantiate the JVM project for SBT with some additional settings
lazy val server = (project in file("server"))
.settings(
name := "server",
version := Settings.version,
scalaVersion := Settings.versions.scala,
scalacOptions ++= Settings.scalacOptions,
libraryDependencies ++= Settings.sharedDependencies.value ++ Settings.jvmDependencies.value ++ Seq(
filters,
guice,
ehcache
),
// connect to the client project
scalaJSProjects := clients,
pipelineStages in Assets := Seq(scalaJSPipeline),
pipelineStages := Seq(digest, gzip),
// compress CSS
LessKeys.compress in Assets := true,
scriptClasspath := Seq("../config/") ++ scriptClasspath.value,
mappings in Universal := (mappings in Universal).value.filter {
case (file, fileName) => !fileName.endsWith("local.conf")
},
mappings in (Compile, packageDoc) := Seq(),
javaOptions in Universal ++= Seq(
"-Dpidfile.path=/dev/null"
),
dockerfile in docker := {
val appDir: File = stage.value
val targetDir = "/app"
new Dockerfile {
from("anapsix/alpine-java:8_jdk")
run("apk", "add", "--update", "bash")
entryPoint(s"$targetDir/bin/${executableScriptName.value}")
copy(appDir, targetDir)
expose(8080)
}
},
imageNames in docker := Seq(
ImageName(
namespace = Some("scalafiddle"),
repository = "scalafiddle-editor",
tag = Some("latest")
),
ImageName(
namespace = Some("scalafiddle"),
repository = "scalafiddle-editor",
tag = Some(version.value)
)
)
)
.enablePlugins(PlayScala, SbtWeb, sbtdocker.DockerPlugin)
.disablePlugins(PlayLayoutPlugin) // use the standard directory layout instead of Play's custom
.aggregate(clients.map(projectToRef): _*)
.dependsOn(sharedJVM)
// loads the Play server project at sbt startup
onLoad in Global := (Command.process("project server", _: State)) compose (onLoad in Global).value