forked from scalameta/scalafmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
238 lines (223 loc) · 6.6 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
import Dependencies._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
def scala211 = "2.11.12"
def scala212 = "2.12.8"
inThisBuild(
List(
organization := "org.scalameta",
homepage := Some(url("https://github.com/scalameta/scalafmt")),
licenses := List(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
developers := List(
Developer(
"olafurpg",
"Ólafur Páll Geirsson",
url("https://geirsson.com")
)
),
scalaVersion := scala212,
crossScalaVersions := List(scala212, scala211),
resolvers += Resolver.sonatypeRepo("releases"),
libraryDependencies ++= List(
scalatest.value % Test,
scalacheck % Test,
scalametaTestkit % Test
)
)
)
name := "scalafmtRoot"
skip in publish := true
addCommandAlias("downloadIdea", "intellij/updateIdea")
commands += Command.command("ci-test") { s =>
val scalaVersion = sys.env.get("TEST") match {
case Some("2.11") => scala211
case _ => scala212
}
val docsTest = if (scalaVersion == scala212) "docs/run" else "version"
s"++$scalaVersion" ::
s"tests/test" ::
s"coreJS/test" ::
docsTest ::
s
}
lazy val dynamic = project
.in(file("scalafmt-dynamic"))
.settings(
moduleName := "scalafmt-dynamic",
description := "Implementation of scalafmt-interfaces",
buildInfoSettings,
buildInfoPackage := "org.scalafmt.dynamic",
buildInfoObject := "BuildInfo",
libraryDependencies ++= List(
"com.geirsson" %% "coursier-small" % "1.3.1",
"com.typesafe" % "config" % "1.3.3",
scalatest.value % Test,
scalametaTestkit % Test
)
)
.dependsOn(interfaces)
.enablePlugins(BuildInfoPlugin)
lazy val interfaces = project
.in(file("scalafmt-interfaces"))
.settings(
moduleName := "scalafmt-interfaces",
description := "Dependency-free, pure Java public interfaces to integrate with Scalafmt through a build tool or editor plugin.",
crossVersion := CrossVersion.disabled,
autoScalaLibrary := false,
resourceGenerators.in(Compile) += Def.task {
val out =
managedResourceDirectories
.in(Compile)
.value
.head / "scalafmt.properties"
val props = new java.util.Properties()
props.put("version", version.value)
IO.write(props, "scalafmt properties", out)
List(out)
}
)
lazy val core = crossProject(JVMPlatform, JSPlatform)
.in(file("scalafmt-core"))
.settings(
moduleName := "scalafmt-core",
addCompilerPlugin(
"org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full
),
buildInfoSettings,
libraryDependencies ++= Seq(
metaconfig.value,
scalameta.value,
// scala-reflect is an undeclared dependency of fansi, see #1252.
// Scalafmt itself does not require scala-reflect.
"org.scala-lang" % "scala-reflect" % scalaVersion.value
)
)
.jsSettings(
libraryDependencies ++= List(
metaconfigHocon.value,
scalatest.value % Test // must be here for coreJS/test to run anything
)
)
.jvmSettings(
fork.in(run).in(Test) := true,
libraryDependencies ++= List(
metaconfigTypesafe.value
)
)
.enablePlugins(BuildInfoPlugin)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val cli = project
.in(file("scalafmt-cli"))
.settings(
moduleName := "scalafmt-cli",
mainClass in assembly := Some("org.scalafmt.cli.Cli"),
assemblyJarName.in(assembly) := "scalafmt.jar",
libraryDependencies ++= Seq(
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
"com.martiansoftware" % "nailgun-server" % "0.9.1",
"com.github.scopt" %% "scopt" % "3.5.0",
// undeclared transitive dependency of coursier-small
"org.scala-lang.modules" %% "scala-xml" % "1.1.1"
),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => Seq("-target:jvm-1.8")
case _ => Seq.empty
}
}
)
.dependsOn(coreJVM, dynamic)
lazy val intellij = project
.in(file("scalafmt-intellij"))
.settings(
buildInfoSettings,
crossScalaVersions := List(scala211),
skip in publish := true,
sources in (Compile, doc) := Nil,
mimaReportBinaryIssues := {},
ideaBuild := "2016.3.2",
test := {}, // no need to download IDEA to run all tests.
ideaEdition := IdeaEdition.Community,
ideaDownloadDirectory in ThisBuild := baseDirectory.value / "idea",
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.0.6",
cleanFiles += ideaDownloadDirectory.value
)
.dependsOn(coreJVM, cli)
.enablePlugins(SbtIdeaPlugin)
lazy val tests = project
.in(file("scalafmt-tests"))
.settings(
skip in publish := true,
libraryDependencies ++= Seq(
// Test dependencies
"com.lihaoyi" %% "scalatags" % "0.6.3",
"org.typelevel" %% "paiges-core" % "0.2.0",
scalametaTestkit
)
)
.dependsOn(
cli
)
lazy val benchmarks = project
.in(file("scalafmt-benchmarks"))
.settings(
skip in publish := true,
moduleName := "scalafmt-benchmarks",
libraryDependencies ++= Seq(
scalametaTestkit
),
javaOptions in run ++= Seq(
"-Djava.net.preferIPv4Stack=true",
"-XX:+AggressiveOpts",
"-XX:+UseParNewGC",
"-XX:+UseConcMarkSweepGC",
"-XX:+CMSParallelRemarkEnabled",
"-XX:+CMSClassUnloadingEnabled",
"-XX:ReservedCodeCacheSize=128m",
"-XX:MaxMetaspaceSize=1024m",
"-XX:SurvivorRatio=128",
"-XX:MaxTenuringThreshold=0",
"-Xss8M",
"-Xms512M",
"-Xmx2G",
"-server"
)
)
.dependsOn(coreJVM)
.enablePlugins(JmhPlugin)
lazy val docs = project
.in(file("scalafmt-docs"))
.settings(
crossScalaVersions := List(scala212),
skip in publish := true,
mdoc := run.in(Compile).evaluated
)
.dependsOn(cli, dynamic)
.enablePlugins(DocusaurusPlugin)
val V = "\\d+\\.\\d+\\.\\d+"
val ReleaseCandidate = s"($V-RC\\d+).*".r
val Milestone = s"($V-M\\d+).*".r
lazy val stableVersion = Def.setting {
version.in(ThisBuild).value.replaceAll("\\+.*", "")
}
lazy val buildInfoSettings: Seq[Def.Setting[_]] = Seq(
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
"scalameta" -> scalametaV,
"nightly" -> version.value,
"stable" -> stableVersion.value,
"scala" -> scalaVersion.value,
"scala211" -> scala211,
"coursier" -> coursier,
"commit" -> sys.process.Process("git rev-parse HEAD").lineStream_!.head,
"timestamp" -> System.currentTimeMillis().toString,
scalaVersion,
sbtVersion
),
buildInfoPackage := "org.scalafmt",
buildInfoObject := "Versions"
)