-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.sbt
186 lines (168 loc) · 8.22 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
/*
Root project: buildAll (not executable)
Aggregates: core, benchmark
Benchmark: executable (sbt benchmark/run)
Make the main JAR of the Chymyst Core library: sbt core/package
*/
/* To compile with printed names and types:
$ sbt
> set scalacOptions in ThisBuild ++= Seq("-Xprint:namer", "-Xprint:typer")
> compile
> exit
*/
val commonSettings = Defaults.coreDefaultSettings ++ Seq(
organization := "io.chymyst",
version := "0.2.1-SNAPSHOT",
scalaVersion := "2.12.4",
crossScalaVersions := Seq("2.11.11", "2.12.4"),
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases"),
"Typesafe releases" at "http://repo.typesafe.com/typesafe/releases"
),
licenses := Seq("Apache License, Version 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("https://chymyst.github.io/chymyst-core/")),
description := "Declarative concurrency framework for Scala - the core library implementing the abstract chemical machine / join calculus",
// scmInfo := Some(ScmInfo(url("git@github.com:Chymyst/chymyst-core.git"), "scm:git:git@github.com:Chymyst/chymyst-core.git", None)),
// developers := List(Developer(id = "winitzki", name = "Sergei Winitzki", email = "swinitzk@hotmail.com", url("https://sites.google.com/site/winitzki"))),
scalacOptions ++= Seq(// https://tpolecat.github.io/2014/04/11/scalac-flags.html
"-deprecation",
"-unchecked",
"-encoding", "UTF-8",
"-feature",
// "-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
// "-opt:l:project", // this is deprecated
"-opt:l:inline",
"-Yvirtpatmat",
"-Ydelambdafy:inline",
// "-Xfatal-warnings",
"-Xlint",
"-Yno-adapted-args", // Makes calling a() fail to substitute a Unit argument into a.apply(x: Unit)
"-Ywarn-dead-code", // N.B. doesn't work well with the ??? hole
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture",
"-Ywarn-unused"
) ++ (//target:jvm-1.8 supported from 2.11.5, warn-unused-import deprecated in 2.12; -Xexperimental is needed for SAM closures
if (scalaBinaryVersion.value == "2.11") {
val revision = scalaVersion.value.split('.').last.toInt
Seq("-Ywarn-unused-import", "-Xexperimental") ++ (
if (revision >= 5) {
Seq("-target:jvm-1.8")
}
else {
Nil
})
}
else Nil
)
++ (
if (scalaBinaryVersion.value == "2.12") Seq("-target:jvm-1.8", "-Ypartial-unification") // (SI-2712 pertains to partial-unification)
else Nil
)
)
lazy val errorsForWartRemover = Seq(Wart.EitherProjectionPartial, Wart.Enumeration, Wart.Equals, Wart.ExplicitImplicitTypes, Wart.FinalCaseClass, Wart.FinalVal, Wart.LeakingSealed, Wart.Return, Wart.StringPlusAny, Wart.TraversableOps, Wart.TryPartial)
lazy val warningsForWartRemover = Seq(Wart.JavaConversions, Wart.IsInstanceOf, Wart.OptionPartial) //Seq(Wart.Any, Wart.AsInstanceOf, Wart.ImplicitConversion, Wart.Option2Iterable, Wart.NoNeedForMonad, Wart.Nothing, Wart.Product, Wart.Serializable, Wart.ToString, Wart.While)
val flightRecorderJVMFlags = Seq(
"-Xmx1G",
"-XX:+UnlockCommercialFeatures",
"-XX:+FlightRecorder",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+DebugNonSafepoints",
"-XX:StartFlightRecording=delay=20s,duration=600s,name=Recording,filename=benchmark.jfr"
)
// Uncomment this and the tut dependency in plugin.sbt in order to build the tutorial.
enablePlugins(TutPlugin)
lazy val disableWarningsForTut = Set("-Ywarn-unused", "-Xlint")
lazy val buildAll = (project in file("."))
.settings(commonSettings: _*)
.settings(
// aggregate in assembly := false, // This would disable assembly in aggregated tasks - not what we want.
tutSourceDirectory := (sourceDirectory in core in Compile).value / "tut",
tutTargetDirectory := baseDirectory.value / "docs", //(crossTarget in core).value / "tut",
scalacOptions in Tut := scalacOptions.value.filterNot(disableWarningsForTut.contains),
name := "chymyst-core-root"
)
.dependsOn(core % "compile->compile;test->test")
.aggregate(core, benchmark)
.disablePlugins(sbtassembly.AssemblyPlugin) // do not create an assembly JAR for `buildAll`, but do create it for aggregate subprojects
lazy val core = (project in file("core"))
.settings(commonSettings: _*)
.settings(
name := "chymyst-core",
wartremoverWarnings in(Compile, compile) ++= warningsForWartRemover,
wartremoverErrors in(Compile, compile) ++= errorsForWartRemover,
libraryDependencies ++= Seq(
// We need guava only because we use its concurrent hash map.
"com.google.guava" % "guava" % "22.0",
// "com.google.code.findbugs" % "jsr305" % "3.0.1", // Include this if there are weird compiler bugs due to guava. See http://stackoverflow.com/questions/10007994/why-do-i-need-jsr305-to-use-guava-in-scala
// "org.javolution" % "javolution" % "6.0.0", // source code not published on Maven Central!
// We need scala-reflect because we use macros.
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scalatest" %% "scalatest" % "3.0.1" % Test,
"org.scalacheck" %% "scalacheck" % "1.13.4" % Test,
"com.lihaoyi" %% "utest" % "0.4.5" % Test,
// We need the "scala-compiler" only in order to debug macros;
// the project or its tests do not actually depend on scala-compiler.
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided
// , "com.nativelibs4java" %% "scalaxy-streams" % "0.4-SNAPSHOT" % Provided // 2.12 is not published on Maven Central!
, "org.sameersingh.scalaplot" % "scalaplot" % "0.0.4" % Test
)
, testFrameworks += new TestFramework("utest.runner.Framework")
)
.disablePlugins(sbtassembly.AssemblyPlugin) // do not create an assembly JAR for `core`
// Benchmarks - users do not need to depend on this.
lazy val benchmark = (project in file("benchmark"))
.settings(commonSettings: _*)
.settings(
name := "benchmark",
// fork in run := true,
test in assembly := {},
// unmanagedJars in Compile += file("lib/JiansenJoin-0.3.6-JoinRun-0.1.0.jar"),// they say it's no longer needed
// Benchmarks shouldl not run concurrently.
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
parallelExecution in Test := false,
// Benchmarks can run under FlightRecorder for profiling.
runFR := {
// see http://jkinkead.blogspot.com/2015/04/running-with-alternate-jvm-args-in-sbt.html
// Parse the arguments typed on the sbt console.
val args = sbt.complete.Parsers.spaceDelimited("[main args]").parsed
// Build up the classpath for the subprocess. Yes, this must be done manually.
// This also ensures that your code will be compiled before you run.
val classpath = (fullClasspath in Compile).value
val classpathString = Path.makeString(classpath.map(_.data))
Fork.java(
// Full options include whatever you want to add, plus the classpath.
ForkOptions(runJVMOptions = javaOptions.value ++ flightRecorderJVMFlags ++ Seq("-classpath", classpathString)),
// You could also add other default arguments here.
"io.chymyst.benchmark.MainApp" +: args
)
},
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.1" % Test
, "com.lihaoyi" %% "ammonite-ops" % "1.0.0-RC7" % Test
)
).dependsOn(core % "compile->compile;test->test")
// Running benchmarks with Flight Recorder.
lazy val runFR = InputKey[Unit]("runFR", "run the project with activated FlightRecorder")
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Publishing to Sonatype Maven repository
publishMavenStyle := true
//
// pomIncludeRepository := { _ => false } // not sure we need this.
// http://www.scala-sbt.org/release/docs/Using-Sonatype.html says we might need it
// because "sometimes we have optional dependencies for special features".
//
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
//
publishArtifact in Test := false
//
/////////////////////////////////////////////////////////////////////////////////////////////////////