-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sbt
More file actions
232 lines (189 loc) · 7.04 KB
/
Copy pathbuild.sbt
File metadata and controls
232 lines (189 loc) · 7.04 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import java.io.PrintWriter
import scala.io.Source
import com.typesafe.sbt.SbtGit.GitKeys._
lazy val breezeVersion = "0.13.2"
lazy val breezeVersionScala13 = "1.3"
lazy val jacksonJsonVersion = "3.6.0-M2"
lazy val jacksonJsonVersionScala13 = "4.1.0-M2"
lazy val scalazVersion = "7.2.27"
lazy val scalazVersionScala13 = "7.4.0-M13"
lazy val scalaTestVersion = "3.0.5"
lazy val scalaTestVersionScala13 = "3.2.15"
javaOptions += "-Xmx2G -Xms1G -XX:MaxPermSize=512M"
javaOptions ++= Seq(
// -J params will be added as jvm paramete
"-J-Xmx2g",
"-J-Xms1g",
"-J-XX:MaxPermSize=512m"
)
// details here on how to post process the generated html and insert mathjax
// http://stackoverflow.com/questions/15996651/is-there-a-way-to-include-math-formulae-in-scaladoc
lazy val mathFormulaInDoc = taskKey[File]("add MathJax script import in doc html to display nice latex formula")
// function that find html files recursively
def listHtmlFile(dir: java.io.File): List[java.io.File] = {
dir.listFiles.toList.flatMap { f =>
if (f.getName.endsWith(".html")) List(f)
else if (f.isDirectory) listHtmlFile(f)
else List[File]()
}
}
val commonPluginSettings = Seq(
mathFormulaInDoc := {
val apiDir = (Compile / doc).value
val docDirs = List(apiDir) // /"some"/"subfolder" // in my case, only api/some/solder is parsed
// will replace this "importTag" by "scriptLine
val importTag = "##import MathJax"
val scriptLine =
"""<script type="text/x-mathjax-config">
|MathJax.Hub.Config({
|tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]},
|"HTML-CSS": {preferredFont: 'TeX'}
|});
|</script>
|<script type="text/javascript" async src="https://cxd.github.io/scala-au.id.cxd.math/javascripts/MathJax-2.7.2/MathJax.js?config=TeX-AMS_CHTML"></script>
| """.stripMargin
// find all html file and apply patch
docDirs.foreach { docDir =>
if (docDir.isDirectory)
listHtmlFile(docDir).foreach { f =>
val content = Source.fromFile(f).getLines().mkString("\n")
if (content.contains(importTag)) {
val writer = new PrintWriter(f)
writer.write(content.replace(importTag, scriptLine))
writer.close()
}
}
}
apiDir
}
)
lazy val commonSettings = Seq(
scalaVersion := "2.11.12",
version := "1.0",
resolvers ++= Resolver.sonatypeOssRepos("public") ++
Resolver.sonatypeOssRepos("snapshots") ++
Resolver.sonatypeOssRepos("releases"),
coverageEnabled := false,
libraryDependencies ++= {
//// scalax io
//"com.github.scala-incubator.io" %% "scala-io-core" % "0.4.3",
// other dependencies here
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n <= 12 =>
List("org.scalanlp" %% "breeze" % breezeVersion,
// native libraries are not included by default. add this if you want them (as of 0.7)
// native libraries greatly improve performance, but increase jar sizes.
"org.scalanlp" %% "breeze-natives" % breezeVersion,
// add the scalaz library
"org.scalaz" %% "scalaz-core" % scalazVersion,
// json4s
"org.json4s" %% "json4s-jackson" % jacksonJsonVersion,
"org.scalatest" %% "scalatest" % scalaTestVersion % "test")
case Some((2, n)) if n > 12 =>
List("org.scalanlp" %% "breeze" % breezeVersionScala13,
// native libraries are not included by default. add this if you want them (as of 0.7)
// native libraries greatly improve performance, but increase jar sizes.
"org.scalanlp" %% "breeze-natives" % breezeVersionScala13,
// add the scalaz library
"org.scalaz" %% "scalaz-core" % scalazVersionScala13,
// json4s
"org.json4s" %% "json4s-jackson" % jacksonJsonVersionScala13,
"org.scalatest" %% "scalatest" % scalaTestVersionScala13 % "test")
case _ => Nil
}
}
)
lazy val uiDependencies = Seq(
libraryDependencies ++= Seq(
// add breeze visualization
"org.scalanlp" %% "breeze-viz" % breezeVersion,
// wrapper around jfreechart
"com.github.wookietreiber" %% "scala-chart" % "0.5.1",
// include kumo for tag cloud generation
"com.kennycason" % "kumo" % "1.8",
// vegas library
"org.vegas-viz" %% "vegas" % "0.3.11",
"org.vegas-viz" %% "vegas-macros" % "0.3.11"
)
)
//test in assembly := {}
lazy val math = (project in file("math"))
.settings(commonSettings: _*)
.settings(commonPluginSettings:_*)
.settings(
name := "au.id.cxd.math",
// note to cross compile for multiple versions of scala use the
// > + compile
// > + assembly
// to manually switch between versions
// > ++ 2.11.12
// > ++ 2.12.17
// > ++ 2.13.10
// this should generate multiple targets
crossScalaVersions := Seq("2.11.12", "2.12.17", "2.13.10"),
assembly / test := {},
assembly / assemblyMergeStrategy := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
).settings(Common.commonPluginSettings: _*)
.enablePlugins(ScalaUnidocPlugin)
lazy val exclude = List(
"jcommon-1.0.16.jar",
"kumo-1.8.jar",
"jfreechart-1.0.13.jar"
)
lazy val examples = (project in file("examples"))
.settings(commonSettings: _*)
.settings(uiDependencies: _*)
.settings(
name := "au.id.cxd.math.examples",
crossScalaVersions := Seq("2.11.12"),
crossPaths := false,
autoScalaLibrary := false,
libraryDependencies ++= Seq(
"jfree" % "jcommon" % "1.0.16" % "provided",
"com.typesafe" % "config" % "1.3.2",
// include kumo for tag cloud generation
"com.kennycason" % "kumo" % "1.8" % "test",
// add breeze visualization
"org.scalanlp" %% "breeze-viz" % breezeVersion % "test"
),
assembly / aggregate := false,
assembly / assemblyExcludedJars := {
val cp = (assembly / fullClasspath).value
cp filter { x => exclude.exists(item => x.data.getName.matches(item)) }
}
)
.settings(Common.commonPluginSettings: _*)
.dependsOn(math)
lazy val swing = (project in file("app"))
.settings(commonSettings: _*)
.settings(uiDependencies: _*)
.settings(
name := "au.id.cxd.math.app",
crossScalaVersions := Seq("2.11.12"),
crossPaths := false,
autoScalaLibrary := false,
assembly / aggregate := false,
libraryDependencies ++= Seq(
// wrapper around jfreechart
//"com.github.wookietreiber" %% "scala-chart" % "0.5.1",
),
assembly / assemblyExcludedJars := {
val cp = (assembly / fullClasspath).value
cp filter { x => exclude.exists(item => x.data.getName.matches(item)) }
}
).settings(Common.commonPluginSettings: _*)
.dependsOn(math)
assembly / assemblyMergeStrategy := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
lazy val root = (project in file("."))
.settings(
// crossScalaVersions must be set to Nil on the aggregating project
crossScalaVersions := Nil,
publish / skip := false
)
.aggregate(math, examples, swing)