-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathbuild.sbt
245 lines (231 loc) · 6.77 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
import Dependencies._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
def scala211 = "2.11.12"
def scala212 = "2.12.6"
inThisBuild(
List(
organization := "com.geirsson", // not org.scalameta because that's a breaking change
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",
"olafurpg@gmail.com",
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
}
s"++$scalaVersion" ::
s"tests/test" ::
s"coreJS/test" ::
s
}
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
)
)
.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"
)
)
.dependsOn(coreJVM)
lazy val big = project
.in(file("scalafmt-big"))
.settings(
moduleName := "scalafmt-big",
crossScalaVersions := List(scala212),
mimaReportBinaryIssues := {},
shadeSettings
)
.dependsOn(cli)
lazy val shadeSettings: List[Setting[_]] = List(
assemblyOption.in(assembly) ~= { _.copy(includeScala = false) },
assemblyShadeRules.in(assembly) := Seq(
ShadeRule
.rename(
"scala.meta.**" -> "org.scalafmt.shaded.meta.@1",
"fastparse.**" -> "org.scalafmt.shaded.fastparse.@1"
)
.inAll,
ShadeRule
.zap(
"scalapb.**",
"com.trueaccord.**"
)
.inAll
),
artifact.in(Compile, packageBin) := artifact.in(Compile, assembly).value,
pomPostProcess := { (node: scala.xml.Node) =>
new scala.xml.transform.RuleTransformer(
new scala.xml.transform.RewriteRule {
override def transform(node: scala.xml.Node): scala.xml.NodeSeq =
node match {
case e: scala.xml.Elem
if e.label == "dependency" &&
e.child.exists { child =>
child.label == "artifactId" &&
child.text.startsWith("scalafmt")
} =>
scala.xml.Comment(s"shaded scalafmt-cli dependency.")
case _ => node
}
}
).transform(node).head
}
) ++ addArtifact(artifact.in(Compile, packageBin), assembly).settings
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)
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:MaxPermSize=1024m",
"-Xss8M",
"-Xms512M",
"-XX:SurvivorRatio=128",
"-XX:MaxTenuringThreshold=0",
"-Xss8M",
"-Xms512M",
"-Xmx2G",
"-server"
)
)
.dependsOn(coreJVM)
.enablePlugins(JmhPlugin)
lazy val website = project
.enablePlugins(PreprocessPlugin, TutPlugin)
.configs(Tut, Preprocess)
.settings(
crossScalaVersions := List(scala212),
skip in publish := true,
tutSourceDirectory := baseDirectory.in(ThisBuild).value / "docs",
sourceDirectory in Preprocess := tutTargetDirectory.value,
target in Preprocess := target.value / "docs",
preprocess in Preprocess := (preprocess in Preprocess).dependsOn(tut).value,
preprocessVars in Preprocess := Map(
"VERSION" -> version.value,
"STABLE_VERSION" -> "1.5.1",
"SCALAMETA_VERSION" -> scalametaV
)
)
.dependsOn(coreJVM, cli)
val V = "\\d+\\.\\d+\\.\\d+"
val ReleaseCandidate = s"($V-RC\\d+).*".r
val Milestone = s"($V-M\\d+).*".r
lazy val stableVersion = Def.setting {
val latestStable = "1.5.1"
version.value match {
case ReleaseCandidate(_) => latestStable
case Milestone(_) => latestStable
case v => v.replaceAll("\\-.*", "")
}
}
lazy val buildInfoSettings: Seq[Def.Setting[_]] = Seq(
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
"scalameta" -> scalametaV,
"nightly" -> version.value,
"stable" -> stableVersion.value,
"scala" -> scalaVersion.value,
"coursier" -> coursier,
"commit" -> sys.process.Process("git rev-parse HEAD").lineStream_!.head,
"timestamp" -> System.currentTimeMillis().toString,
scalaVersion,
sbtVersion
),
buildInfoPackage := "org.scalafmt",
buildInfoObject := "Versions"
)