forked from inkytonik/kiama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
242 lines (217 loc) · 8.1 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
import com.typesafe.sbt.pgp.PgpKeys.{publishSigned, publishLocalSigned}
import scalariform.formatter.preferences._
// Settings for entire build
ThisBuild/version := "2.5.0-SNAPSHOT"
ThisBuild/organization := "org.bitbucket.inkytonik.kiama"
ThisBuild/scalaVersion := "2.13.4"
ThisBuild/crossScalaVersions := Seq("3.0.0-M2", "2.13.4", "2.12.13", "2.11.12")
ThisBuild/scalacOptions := {
// Turn on all lint warnings, except:
// - stars-align: incorrectly reports problems if pattern matching of
// unapplySeq extractor doesn't match sequence directly
// - non-local-return: sometimes we just prefer to do this
val lintOption =
if (scalaVersion.value.startsWith("2.13"))
"-Xlint:-stars-align,-nonlocal-return,_"
else
"-Xlint:-stars-align,_"
if (scalaVersion.value.startsWith("3"))
Seq(
"-deprecation",
"-feature",
"-language:higherKinds",
"-sourcepath", baseDirectory.value.getAbsolutePath,
"-unchecked",
"-Xfatal-warnings",
"-Xmigration"
// FIXME: should we have a -Xlint replacement?
)
else
Seq(
"-deprecation",
"-feature",
"-language:higherKinds",
"-sourcepath", baseDirectory.value.getAbsolutePath,
"-unchecked",
"-Xcheckinit",
"-Xfatal-warnings",
"-Xsource:3",
lintOption
)
}
ThisBuild/resolvers ++=
Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
)
ThisBuild/logLevel := Level.Info
ThisBuild/shellPrompt := {
state =>
Project.extract(state).currentRef.project + " " + version.value+
" " + scalaVersion.value + "> "
}
ThisBuild/mainClass := None
// Common project settings
val commonSettings =
Seq(
unmanagedSourceDirectories in Compile ++= {
val sourceDir = (sourceDirectory in Compile).value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
Seq(sourceDir / "scala-2.11", sourceDir / "scala-2.11+", sourceDir / "scala-2.12-")
case Some((2, 12)) =>
Seq(sourceDir / "scala-2.not11", sourceDir / "scala-2.11+", sourceDir / "scala-2.12-")
case Some((2, 13) | (3, 0)) =>
Seq(sourceDir / "scala-2.not11", sourceDir / "scala-2.11+", sourceDir / "scala-2.13")
case version =>
sys.error(s"unexpected Scala version $version")
}
},
libraryDependencies ++=
Seq(
"org.scalacheck" %% "scalacheck" % "1.15.2" % "test",
"org.scalatest" %% "scalatest-funsuite" % "3.2.3" % "test",
"org.scalatest" %% "scalatest-shouldmatchers" % "3.2.3" % "test",
"org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0" % "test"
),
// Formatting
scalariformPreferences := scalariformPreferences.value
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(DanglingCloseParenthesis, Force)
.setPreference(IndentSpaces, 4)
.setPreference(SpaceBeforeColon, true)
.setPreference(SpacesAroundMultiImports, false),
// Publishing
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishMavenStyle := true,
Test/publishArtifact := true,
pomIncludeRepository := { _ => false },
pomExtra := (
<url>https://github.com/inkytonik/kiama</url>
<licenses>
<license>
<name>Mozilla Public License, v. 2.0</name>
<url>http://mozilla.org/MPL/2.0/</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/inkytonik/kiama</url>
<connection>scm:hg:https://github.com/inkytonik/kiama</connection>
</scm>
<developers>
<developer>
<id>inkytonik</id>
<name>Tony Sloane</name>
<url>https://github.com/inkytonik</url>
</developer>
</developers>
)
)
// Project configuration:
// - core project containing main Kiama functionality, including its tests
// - extras project containing utilities, including their tests and examples
// - kiama (root) project aggregates core and extras
def setupProject(project : Project, projectName : String) : Project =
project.settings(
name := projectName
)
def setupSubProject(project : Project, projectName : String) : Project =
setupProject(
project,
projectName
).enablePlugins(
ScalaUnidocPlugin
).settings(
commonSettings : _*
)
val noPublishSettings =
Seq(
publish := {},
publishLocal := {},
publishSigned := {},
publishLocalSigned := {}
)
val extrasProject = ProjectRef(file("."), "extras")
lazy val core =
setupSubProject(
project in file("core"),
"kiama"
).settings(
libraryDependencies ++=
Seq(
// Caching:
"com.google.guava" % "guava" % "27.1-jre"
),
console/initialCommands := """
import org.bitbucket.inkytonik.kiama._
import rewriting.Rewriter._
""".stripMargin,
// Unidoc so we combine docs from core (but not extras)
Compile/doc := (ScalaUnidoc/doc).value,
Test/doc := (TestScalaUnidoc/doc).value,
ScalaUnidoc/unidoc/target := crossTarget.value / "api",
TestScalaUnidoc/unidoc/target := crossTarget.value / "test-api",
ScalaUnidoc/unidoc/scalacOptions ++=
Seq(
"-doc-source-url",
"https://github.com/inkytonik/kiama/blob/master€{FILE_PATH}.scala"
),
TestScalaUnidoc/unidoc/scalacOptions := (ScalaUnidoc/unidoc/scalacOptions).value,
ScalaUnidoc/unidoc/unidocProjectFilter := inAnyProject -- inProjects(extrasProject),
TestScalaUnidoc/unidoc/unidocProjectFilter := (ScalaUnidoc/unidoc/unidocProjectFilter).value
)
lazy val extras =
setupSubProject(
project in file("extras"),
"kiama-extras"
).settings(
libraryDependencies ++=
Seq(
// Command-line handling:
"org.rogach" %% "scallop" % "4.0.1",
// Language server protocol:
"org.eclipse.lsp4j" % "org.eclipse.lsp4j" % "0.10.0",
"com.google.code.gson" % "gson" % "2.8.2",
// REPLs:
"jline" % "jline" % "2.14.6"
),
javaOptions ++= Seq("-Xss8M"),
fork := true,
run/connectInput := true,
run/outputStrategy := Some(StdoutOutput),
Test/console/initialCommands :=
(Test/console/initialCommands).value + """
import org.bitbucket.inkytonik.kiama._
import example.json.PrettyPrinter._
import example.json.JSONTree._
""".stripMargin,
Compile/doc/scalacOptions ++=
Seq(
"-doc-source-url",
"https://github.com/inkytonik/kiama/blob/master€{FILE_PATH}.scala"
),
Test/doc/scalacOptions := (Compile/doc/scalacOptions).value
).settings(
inConfig(Test)(baseAssemblySettings)
).settings(
// Test/assembly/test := {},
Test/assembly/assemblyJarName := s"${name.value}-assembly-${version.value}-tests.jar"
).dependsOn(
core % "compile; test->test"
)
lazy val root =
setupProject(
project in file("."),
"root"
).settings(
noPublishSettings : _*
).aggregate(
core, extras
)