-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sbt
140 lines (124 loc) · 6.49 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
// See http://www.scala-js.org/doc/sbt/cross-building.html
// and https://github.com/scala-js/scalajs-cross-compile-example/blob/master/build.sbt
// for cross building configuration.
// There are 3 projects defined : root, appJS and appJVM.
// root is just an aggregation of appJS and appJVM but can be imported in a IDE (to edit the build definition) as well.
// appJS and appJVM share the appSharedSettings
// appJS uses scalaJSSettings which is specific for javascript development.
lazy val root = project.in(file(".")).aggregate(sharedJs, sharedJvm, appJS, appJVM, server).settings(
name := "Monix Scala-js Ionic Starter Application Tabs (Root)",
publish := {},
publishLocal := {}
)
/// Defined a task that returns the function to compile some scala files to HTML files (using ScalaTags).
/// the OptMode is defined in Build.scala
lazy val getCompileToHtmlPartialFunctionTask = taskKey[(String,OptMode,String) => Unit]("Get the partial function to compile scala files to HTML")
/// Defined a task that compiles (for the fastopt stage) all the files contained in htmlScalaSourceDir to HTML files in the outputCompiledHTML folder.
lazy val compileHtmlDevTask = taskKey[Unit]("Compile all scala files contained in htmlScalaSourceDir (defined in the Build.scala) to HTML")
/// Defined a task that compiles (for the fullopt stage) all the files contained in htmlScalaSourceDir to HTML files in the outputCompiledHTML folder.
lazy val compileHtmlProdTask = taskKey[Unit]("Compile all scala files contained in htmlScalaSourceDir (defined in the Build.scala) to HTML")
/// Define a task to clean up the output JS directory
lazy val cleanOutputJS = taskKey[Unit]("Clean the output JS directory")
///////////////////// END OF TAKS DEFINITION ///////////
lazy val scalaV = "2.11.8"
lazy val shared = (crossProject.crossType(CrossType.Pure) in file("shared")).
settings(
scalaVersion := scalaV,
libraryDependencies ++= Seq(
"org.scala-js" %% "scalajs-stubs" % scalaJSVersion % "provided"
)
)
//jsConfigure(_ enablePlugins ScalaJSPlay).
// .jsSettings(sourceMapsBase := baseDirectory.value / "..")
lazy val sharedJvm = shared.jvm
lazy val sharedJs = shared.js
lazy val server = (project in file("server")).settings(
scalaVersion := scalaV,
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
libraryDependencies ++= Seq(
"io.monix" %% "monix" % "2.0.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.1.0"
),
// Heroku specific
herokuAppName in Compile := "monifu-ionic-sample",
herokuSkipSubProjects in Compile := false
)
.enablePlugins(PlayScala)
.dependsOn(sharedJvm)
lazy val appSharedSettings = Seq(
version := "0.2-SNAPSHOT",
scalaVersion := scalaV,
unmanagedSourceDirectories in Compile += baseDirectory.value / ".." / "app-shared" / "src" / "main" / "scala",
// Download and link sources for library dependencies (when using sbt eclipse)
EclipseKeys.withSource := true,
// do not skip the parents so that the root project can be imported in eclipse.
EclipseKeys.skipParents in ThisBuild := false,
/// add local maven .m2 repo to resolve dependencies.
resolvers ++= Seq("Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots", Resolver.mavenLocal)
)
lazy val appJS = project.in(file("app-js"))
// Turn this project into a Scala.js project by enabling ScalaJSPlugin
.enablePlugins(ScalaJSPlugin)
.settings(appSharedSettings: _*)
.settings(
// Add JS-specific settings here
name := "Monix Scala-js Ionic Starter Application Tabs",
normalizedName := "monix-ionic",
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.1",
"com.greencatsoft" %%% "scalajs-angular" % "0.7",
"com.github.benhutchison" %%% "prickle" % "1.1.9",
"io.monix" %%% "monix" % "2.0.0"
),
jsDependencies += RuntimeDOM,
/// Webjars dependencies
jsDependencies += "org.webjars" % "ionic" % "1.1.0" / "ionic.bundle.js" minified "ionic.bundle.min.js",
// jsDependencies += "org.webjars" % "angular-sanitize" % "1.3.11" / "angular-sanitize.min.js",
skip in packageJSDependencies := false,
////// SourceMaps configuration ////////////////////////
emitSourceMaps in(Compile, fastOptJS) := true,
// Don't emit source Maps for fullOpt stage.
emitSourceMaps in(Compile, fullOptJS) := false,
/// a symlink to the src folder may need to be added in the ionic/www folder in order to make SourceMaps work.
relativeSourceMaps := true,
///// launcher js configuration ////////////////////////
/// See http://www.scala-js.org/doc/tutorial.html : Automatically Creating a Launcher
persistLauncher in Compile := true,
persistLauncher in Test := false,
//// HTML5 Cordova, web application related modifications below
/// Change the crossTarget of different tasks to output the fastOpt, fullOpt, jsdeps and launcher JS files in a custom output directory.
crossTarget in(Compile, fastOptJS) := outputCompiledJS,
crossTarget in(Compile, packageScalaJSLauncher) := outputCompiledJS,
crossTarget in(Compile, packageJSDependencies) := outputCompiledJS,
crossTarget in(Compile, fullOptJS) := outputCompiledJS,
cleanOutputJS := {
implicit val s: TaskStreams = streams.value
cleanOutputJSDir()
}
)
.dependsOn(sharedJs)
lazy val appJVM = project.in(file("app-jvm"))
.settings(appSharedSettings: _*)
.settings(
// Add JVM-specific settings here
name := "Monix Scala-js Ionic Starter Application Tabs (JVM)",
normalizedName := "monix-ionic",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "scalatags" % "0.5.4"
),
getCompileToHtmlPartialFunctionTask := {
implicit val classPathFiles: Seq[sbt.File] = (fullClasspath in Runtime).value.files
implicit val s: TaskStreams = streams.value
// return the partially applied function "compileToHtml" (a method defined in Build.scala with a (String,OptMode,String) => Unit signature)
// the result of the task (accesible with .value) is then a function that can be applied.
compileToHtml
},
compileHtmlDevTask := {
getCompileToHtmlPartialFunctionTask.value("", FastOpt, moduleName.value)
},
compileHtmlProdTask := {
getCompileToHtmlPartialFunctionTask.value("", FullOpt, moduleName.value)
}
)
addCommandAlias("watch", "~ ;packageJSDependencies ;packageScalaJSLauncher ;compileHtmlDevTask ;fastOptJS")
addCommandAlias("dist", ";cleanOutputJS ;packageJSDependencies ;packageScalaJSLauncher ;compileHtmlProdTask ;fullOptJS")