forked from NetLogo/NetLogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
329 lines (308 loc) · 14.4 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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
import org.scalajs.sbtplugin.cross.{ CrossProject, CrossType }
import ModelsLibrary.modelsDirectory
import Extensions.{ excludedExtensions, extensionRoot }
import NetLogoBuild.{ all, autogenRoot, cclArtifacts, includeInPackaging,
marketingVersion, numericMarketingVersion, netlogoVersion, shareSourceDirectory }
import Docs.htmlDocs
import Dump.dumpClassName
import Testing.{ testTempDirectory, testChecksumsClass }
// these settings are common to ALL BUILDS
// if it doesn't belong in every build, it can't go in here
lazy val commonSettings = Seq(
organization := "org.nlogo",
licenses += ("GPL-2.0", url("http://opensource.org/licenses/GPL-2.0")),
javaSource in Compile := baseDirectory.value / "src" / "main",
javaSource in Test := baseDirectory.value / "src" / "test",
onLoadMessage := "",
testTempDirectory := (baseDirectory.value.getParentFile / "tmp").getAbsoluteFile,
ivyLoggingLevel := UpdateLogging.Quiet
)
// These settings are common to all builds involving scala
// Any scala-specific settings should change here (and thus for all projects at once)
lazy val scalaSettings = Seq(
scalaVersion := "2.12.4",
scalaSource in Compile := baseDirectory.value / "src" / "main",
scalaSource in Test := baseDirectory.value / "src" / "test",
crossPaths := false, // don't cross-build for different Scala versions
scalacOptions ++=
"-deprecation -unchecked -feature -Xcheckinit -encoding us-ascii -target:jvm-1.8 -opt:l:method -Xlint -Xfatal-warnings"
.split(" ").toSeq,
// we set doc options until https://github.com/scala/bug/issues/10402 is fixed
scalacOptions in Compile in doc --= "-Xlint -Xfatal-warnings".split(" ").toSeq
)
// These settings are common to all builds that compile against Java
// Any java-specific settings should change here (and thus for all java projects at once)
lazy val jvmSettings = Seq(
javaSource in Compile := baseDirectory.value / "src" / "main",
javaSource in Test := baseDirectory.value / "src" / "test",
publishArtifact in Test := true,
javacOptions ++=
"-g -deprecation -encoding us-ascii -Werror -Xlint:all -Xlint:-serial -Xlint:-fallthrough -Xlint:-path -source 1.8 -target 1.8"
.split(" ").toSeq
)
// These are scalatest-specific settings
// Any scalatest-specific settings should change here
lazy val scalatestSettings = Seq(
// show test failures again at end, after all tests complete.
// T gives truncated stack traces; change to G if you need full.
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oS"),
logBuffered in testOnly in Test := false,
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.4" % "test"
)
)
lazy val flexmarkDependencies = {
val flexmarkVersion = "0.20.0"
Seq(
libraryDependencies ++= Seq(
"com.vladsch.flexmark" % "flexmark" % flexmarkVersion,
"com.vladsch.flexmark" % "flexmark-ext-autolink" % flexmarkVersion,
"com.vladsch.flexmark" % "flexmark-ext-escaped-character" % flexmarkVersion,
"com.vladsch.flexmark" % "flexmark-ext-typographic" % flexmarkVersion,
"com.vladsch.flexmark" % "flexmark-util" % flexmarkVersion
)
)
}
lazy val mockDependencies = Seq(
libraryDependencies ++= Seq(
"org.jmock" % "jmock" % "2.8.1" % "test",
"org.jmock" % "jmock-legacy" % "2.8.1" % "test",
"org.jmock" % "jmock-junit4" % "2.8.1" % "test",
"org.reflections" % "reflections" % "0.9.10" % "test",
"org.slf4j" % "slf4j-nop" % "1.7.12" % "test"
)
)
lazy val scalastyleSettings = Seq(
scalastyleTarget in Compile := {
baseDirectory.value.getParentFile / "target" / s"scalastyle-result-${name.value}.xml"
})
def publicationSettings(repository: String) =
Seq(
bintrayRepository := repository,
bintrayOrganization := Some("netlogo"))
lazy val root =
project.in(file(".")).
aggregate(netlogo, parserJVM)
lazy val netlogo = project.in(file("netlogo-gui")).
dependsOn(parserJVM % "test->test;compile->compile").
settings(NetLogoBuild.settings: _*).
settings(includeInPackaging(parserJVM): _*).
settings(shareSourceDirectory("netlogo-core"): _*).
settings(commonSettings: _*).
settings(jvmSettings: _*).
settings(scalaSettings: _*).
settings(scalatestSettings: _*).
settings(JFlexRunner.settings: _*).
settings(EventsGenerator.settings: _*).
settings(Docs.settings: _*).
settings(publicationSettings("NetLogo-JVM"): _*).
settings(flexmarkDependencies).
settings(Defaults.coreDefaultSettings ++
Testing.settings ++
Testing.useLanguageTestPrefix("org.nlogo.headless.Test") ++
Packaging.settings ++
Running.settings ++
Dump.settings ++
Scaladoc.settings ++
ChecksumsAndPreviews.settings ++
Extensions.settings ++
InfoTab.infoTabTask ++
ModelsLibrary.settings ++
NativeLibs.nativeLibsTask ++
NetLogoWebExport.settings ++
GUISettings.settings ++
Depend.dependTask: _*).
settings(
name := "NetLogo",
version := "6.0.4",
isSnapshot := true,
mainClass in Compile := Some("org.nlogo.app.App"),
modelsDirectory := baseDirectory.value.getParentFile / "models",
extensionRoot := (baseDirectory.value.getParentFile / "extensions").getAbsoluteFile,
autogenRoot := baseDirectory.value.getParentFile / "autogen",
unmanagedSourceDirectories in Test += baseDirectory.value / "src" / "tools",
testChecksumsClass in Test := "org.nlogo.headless.TestChecksums",
resourceDirectory in Compile := baseDirectory.value / "resources",
unmanagedResourceDirectories in Compile ++= (unmanagedResourceDirectories in Compile in sharedResources).value,
resourceGenerators in Compile += I18n.resourceGeneratorTask.taskValue,
threed := { System.setProperty("org.nlogo.is3d", "true") },
nogen := { System.setProperty("org.nlogo.noGenerator", "true") },
libraryDependencies ++= Seq(
"org.ow2.asm" % "asm-all" % "5.0.4",
"org.picocontainer" % "picocontainer" % "2.13.6",
"log4j" % "log4j" % "1.2.16",
"javax.media" % "jmf" % "2.1.1e",
"commons-codec" % "commons-codec" % "1.10",
"org.parboiled" %% "parboiled" % "2.1.3",
"org.jogamp.jogl" % "jogl-all" % "2.3.2",
"org.jogamp.gluegen" % "gluegen-rt" % "2.3.2",
"org.jhotdraw" % "jhotdraw" % "6.0b1" % "provided,optional" from cclArtifacts("jhotdraw-6.0b1.jar"),
"org.jmock" % "jmock" % "2.5.1" % "test",
"org.jmock" % "jmock-legacy" % "2.5.1" % "test",
"org.jmock" % "jmock-junit4" % "2.5.1" % "test",
"org.apache.httpcomponents" % "httpclient" % "4.2",
"org.apache.httpcomponents" % "httpmime" % "4.2",
"com.googlecode.json-simple" % "json-simple" % "1.1.1",
"com.fifesoft" % "rsyntaxtextarea" % "2.6.0",
"com.typesafe" % "config" % "1.3.1",
"net.lingala.zip4j" % "zip4j" % "1.3.2"
),
all := {},
all := {
all.dependsOn(
htmlDocs,
packageBin in Test,
Extensions.extensions,
NativeLibs.nativeLibs,
ModelsLibrary.modelIndex,
Scaladoc.apiScaladoc).value
}
)
lazy val threed = TaskKey[Unit]("threed", "enable NetLogo 3D")
lazy val nogen = TaskKey[Unit]("nogen", "disable bytecode generator")
lazy val headless = (project in file ("netlogo-headless")).
dependsOn(parserJVM % "test-internal->test;compile-internal->compile").
enablePlugins(org.nlogo.build.PublishVersioned).
settings(commonSettings: _*).
settings(scalaSettings: _*).
settings(scalastyleSettings: _*).
settings(jvmSettings: _*).
settings(scalatestSettings: _*).
settings(mockDependencies: _*).
settings(Scaladoc.settings: _*).
settings(Testing.settings: _*).
settings(Testing.useLanguageTestPrefix("org.nlogo.headless.lang.Test"): _*).
settings(Depend.dependTask: _*).
settings(Extensions.settings: _*).
settings(publicationSettings("NetLogoHeadless"): _*).
settings(JFlexRunner.settings: _*).
settings(includeInPackaging(parserJVM): _*).
settings(shareSourceDirectory("netlogo-core"): _*).
settings(Dump.settings: _*).
settings(ChecksumsAndPreviews.settings: _*).
settings(
name := "NetLogoHeadless",
version := "6.0.4",
isSnapshot := true,
autogenRoot := (baseDirectory.value.getParentFile / "autogen").getAbsoluteFile,
extensionRoot := baseDirectory.value.getParentFile / "extensions",
mainClass in Compile := Some("org.nlogo.headless.Main"),
nogen := { System.setProperty("org.nlogo.noGenerator", "true") },
libraryDependencies ++= Seq(
"org.ow2.asm" % "asm-all" % "5.0.4",
"org.parboiled" %% "parboiled" % "2.1.3",
"commons-codec" % "commons-codec" % "1.10"
),
(fullClasspath in Runtime) ++= (fullClasspath in Runtime in parserJVM).value,
resourceDirectory in Compile := baseDirectory.value / "resources" / "main",
resourceDirectory in Test := baseDirectory.value.getParentFile / "test",
testChecksumsClass in Test := "org.nlogo.headless.misc.TestChecksums",
dumpClassName := "org.nlogo.headless.misc.Dump",
excludedExtensions := Seq("arduino", "bitmap", "csv", "gis", "gogo", "ls", "nw", "palette", "sound", "vid", "view2.5d"),
all := { val _ = (
(packageBin in Compile).value,
(packageBin in Test).value,
(compile in Test).value,
Extensions.extensions
)}
)
// this project exists as a wrapper for the mac-specific NetLogo components
lazy val macApp = project.in(file("mac-app")).
settings(commonSettings: _*).
settings(jvmSettings: _*).
settings(scalaSettings: _*).
settings(JavaPackager.mainArtifactSettings: _*).
settings(NativeLibs.cocoaLibsTask).
settings(Running.settings).
settings(
mainClass in Compile in run := Some("org.nlogo.app.MacApplication"),
fork in run := true,
name := "NetLogo-Mac-App",
compile in Compile := {
((compile in Compile) dependsOn (packageBin in Compile in netlogo)).value
},
unmanagedJars in Compile += (packageBin in Compile in netlogo).value,
libraryDependencies ++= Seq(
"net.java.dev.jna" % "jna" % "4.2.2",
"ca.weblite" % "java-objc-bridge" % "1.0.0"),
libraryDependencies ++= (libraryDependencies in netlogo).value,
libraryDependencies ++= (libraryDependencies in parserJVM).value,
run in Compile := {
((run in Compile) dependsOn NativeLibs.cocoaLibs).evaluated
},
javaOptions in run += "-Djava.library.path=" + (Seq(
baseDirectory.value / "natives" / "macosx-universal" / "libjcocoa.dylib") ++
((baseDirectory in netlogo).value / "natives" / "macosx-universal" * "*.jnilib").get).mkString(":"),
artifactPath in Compile in packageBin := target.value / "netlogo-mac-app.jar",
javacOptions ++= Seq("-bootclasspath", System.getProperty("java.home") + "/lib/rt.jar"))
// this project is all about packaging NetLogo for distribution
lazy val dist = project.in(file("dist")).
settings(NetLogoBuild.settings: _*).
settings(NetLogoPackaging.settings(netlogo, macApp, behaviorsearchProject): _*)
lazy val sharedResources = (project in file ("shared")).
settings(commonSettings: _*).
settings(scalaSettings: _*).
settings(scalastyleSettings: _*).
settings(unmanagedResourceDirectories in Compile += baseDirectory.value / "resources" / "main")
lazy val macros = (project in file("macros")).
dependsOn(sharedResources).
settings(commonSettings: _*).
settings(scalaSettings: _*).
settings(scalastyleSettings: _*).
settings(libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value)
lazy val parser = CrossProject("parser", file("."),
new CrossType {
override def projectDir(crossBase: File, projectType: String): File =
crossBase / s"parser-$projectType"
override def sharedSrcDir(projectBase: File, conf: String): Option[File] =
Some(projectBase / "parser-core" / "src" / conf)
}).
settings(commonSettings: _*).
settings(scalaSettings: _*).
settings(scalastyleSettings: _*).
settings(publicationSettings("NetLogoHeadless"): _*).
settings(
isSnapshot := true,
name := "parser",
version := "0.2.2",
unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile / "parser-core" / "src" / "main",
unmanagedSourceDirectories in Test += baseDirectory.value.getParentFile / "parser-core" / "src" / "test").
jsConfigure(_.dependsOn(sharedResources % "compile-internal->compile")).
jsConfigure(_.dependsOn(macros % "compile-internal->compile;test-internal->compile")).
jsSettings(
name := "parser-js",
scalaModuleInfo := scalaModuleInfo.value map { _.withOverrideScalaVersion(true) },
resolvers += Resolver.sonatypeRepo("releases"),
parallelExecution in Test := false,
libraryDependencies ++= {
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport.toScalaJSGroupID
Seq(
"org.scala-lang.modules" %%%! "scala-parser-combinators" % "1.0.5",
"org.scalatest" %%%! "scalatest" % "3.0.0" % "test",
// scalatest doesn't yet play nice with scalacheck 1.13.0
"org.scalacheck" %%%! "scalacheck" % "1.13.4" % "test"
)}).
jvmConfigure(_.dependsOn(sharedResources)).
jvmSettings(jvmSettings: _*).
jvmSettings(scalatestSettings: _*).
jvmSettings(
mappings in (Compile, packageBin) ++= mappings.in(sharedResources, Compile, packageBin).value,
mappings in (Compile, packageSrc) ++= mappings.in(sharedResources, Compile, packageSrc).value,
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.5"
)
lazy val parserJVM = parser.jvm
lazy val parserJS = parser.js
// only exists for scalastyling
lazy val parserCore = (project in file("parser-core")).
settings(scalastyleSettings: _*).
settings(skip in (Compile, compile) := true)
// only exists for scalastyling
lazy val netlogoCore = (project in file("netlogo-core")).
settings(scalastyleSettings: _*).
settings(skip in (Compile, compile) := true)
// only exists for packaging
lazy val behaviorsearchProject: Project =
project.in(file("behaviorsearch"))
.dependsOn(netlogo % "test-internal->test;compile-internal->compile")
.settings(description := "subproject of NetLogo")