-
Notifications
You must be signed in to change notification settings - Fork 72
/
Build.scala
298 lines (280 loc) · 11.2 KB
/
Build.scala
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
import java.io.File
import ReleaseExtras.ReleaseExtrasKeys._
import ReleaseExtras._
import com.typesafe.sbt.pgp.PgpKeys._
import org.stormenroute.mecha._
import sbt.Keys._
import sbt._
import sbtrelease.ReleasePlugin
import sbtrelease.ReleasePlugin.autoImport._
import sbtrelease.ReleaseStateTransformations._
object ScalaMeterBuild extends MechaRepoBuild {
def repoName = "scalameter"
val publishUser = "SONATYPE_USER"
val publishPass = "SONATYPE_PASS"
val userPass = for {
user <- sys.env.get(publishUser)
pass <- sys.env.get(publishPass)
} yield (user, pass)
val publishCreds: Seq[Setting[_]] = Seq(userPass match {
case Some((user, pass)) =>
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", user, pass)
case None =>
// prevent publishing
publish := streams.value.log.info("Publishing to Sonatype is disabled since the \"" + publishUser + "\" and/or \"" + publishPass + "\" environment variables are not set.")
})
val releasePluginSettings = Seq(
releaseBranchName := s"version/${(version in ThisBuild).value}",
examples.repo := "[email protected]:scalameter/scalameter-examples.git",
examples.tag := "v%s",
examples.tagComment := "Release %s",
examples.commitMessage := "Set ScalaMeter version to %s",
examples.scalaMeterVersionFile := "version.sbt",
examples.scalaMeterVersionFileContent := globalVersionString,
releaseCommitMessage := s"Set version to ${(version in ThisBuild).value}",
releasePublishArtifactsAction := publishSigned.value,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runTest,
setReleaseVersion,
commitReleaseVersion,
branchRelease,
setNextVersion,
commitNextVersion,
pushChanges,
bumpUpVersionInExamples
)
)
val scalaMeterSettings = MechaRepoPlugin.defaultSettings ++ publishCreds ++ Seq(
name := "scalameter",
organization := "com.storm-enroute",
scalaVersion := "2.13.2",
crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.2"),
scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-Xlint", "-Xfuture"),
libraryDependencies ++= dependencies(scalaVersion.value),
parallelExecution in Test := false,
fork := true,
fork in run := true,
fork in Test := true,
outputStrategy := Some(StdoutOutput),
connectInput in run := true,
connectInput in Test := true,
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases"
),
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet,
publishMavenStyle := true,
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")
},
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
pomExtra :=
<url>http:https://scalameter.github.io/</url>
<licenses>
<license>
<name>BSD-style</name>
<url>http:https://opensource.org/licenses/BSD-3-Clause</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>[email protected]:scalameter/scalameter.git</url>
<connection>scm:git:[email protected]:scalameter/scalameter.git</connection>
</scm>
<developers>
<developer>
<id>axel22</id>
<name>Aleksandar Prokopec</name>
<url>http:https://axel22.github.com/</url>
</developer>
</developers>
)
def dependencies(scalaVersion: String) = {
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, 13)) => List(
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
"junit" % "junit" % "4.12" % "test",
"org.apache.commons" % "commons-math3" % "3.2",
"org.scala-sbt" % "test-interface" % "1.0",
"org.scala-lang.modules" %% "scala-xml" % "2.0.1",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.11.3",
"commons-io" % "commons-io" % "2.4",
"io.spray" %% "spray-json" % "1.3.5",
"org.jline" % "jline" % "3.10.0"
)
case Some((2, 12)) => List(
"org.scalatest" % "scalatest_2.12" % "3.0.0" % "test",
"junit" % "junit" % "4.12" % "test",
"org.apache.commons" % "commons-math3" % "3.2",
"org.scala-sbt" % "test-interface" % "1.0",
"org.scala-lang.modules" % "scala-xml_2.12" % "1.0.5",
"org.scala-lang.modules" % "scala-parser-combinators_2.12" % "1.0.4",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.11.3",
"commons-io" % "commons-io" % "2.4",
"io.spray" % "spray-json_2.12" % "1.3.2",
"org.jline" % "jline" % "3.10.0"
)
case Some((2, 11)) => List(
"org.scalatest" %% "scalatest" % "3.0.0" % "test",
"junit" % "junit" % "4.12" % "test",
"org.apache.commons" % "commons-math3" % "3.2",
"org.scala-sbt" % "test-interface" % "1.0",
"org.scala-lang.modules" %% "scala-xml" % "1.0.1",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.11.3",
"commons-io" % "commons-io" % "2.4",
"io.spray" %% "spray-json" % "1.3.2",
"org.jline" % "jline" % "3.10.0"
)
case _ => Nil
}
}
val scalaMeterCoreSettings = MechaRepoPlugin.defaultSettings ++ publishCreds ++ Seq(
name := "scalameter-core",
organization := "com.storm-enroute",
scalaVersion := "2.13.0",
crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0"),
scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-Xlint", "-Xfuture"),
libraryDependencies ++= coreDependencies(scalaVersion.value),
parallelExecution in Test := false,
fork := true,
fork in run := true,
fork in Test := true,
outputStrategy := Some(StdoutOutput),
connectInput in run := true,
connectInput in Test := true,
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases"
),
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet,
publishMavenStyle := true,
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")
},
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
pomExtra :=
<url>http:https://scalameter.github.io/</url>
<licenses>
<license>
<name>BSD-style</name>
<url>http:https://opensource.org/licenses/BSD-3-Clause</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>[email protected]:scalameter/scalameter.git</url>
<connection>scm:git:[email protected]:scalameter/scalameter.git</connection>
</scm>
<developers>
<developer>
<id>axel22</id>
<name>Aleksandar Prokopec</name>
<url>http:https://axel22.github.com/</url>
</developer>
</developers>
)
def coreDependencies(scalaVersion: String) = CrossVersion.partialVersion(scalaVersion) match {
case Some((2, 13)) => List(
"io.github.classgraph" % "classgraph" % "4.8.78",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.1",
"org.scalacheck" %% "scalacheck" % "1.14.0" % "test",
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
"junit" % "junit" % "4.12" % "test",
"com.novocode" % "junit-interface" % "0.11" % "test",
"org.apache.commons" % "commons-math3" % "3.2",
"org.apache.commons" % "commons-lang3" % "3.4",
"org.scala-lang.modules" %% "scala-xml" % "2.0.1",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2",
"org.ow2.asm" % "asm" % "5.0.4",
"org.jline" % "jline" % "3.10.0"
)
case Some((2, 12)) => List(
"io.github.classgraph" % "classgraph" % "4.8.78",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.1",
"org.scalacheck" % "scalacheck_2.12" % "1.13.4" % "test",
"org.scalatest" % "scalatest_2.12" % "3.0.0" % "test",
"junit" % "junit" % "4.12" % "test",
"com.novocode" % "junit-interface" % "0.11" % "test",
"org.apache.commons" % "commons-math3" % "3.2",
"org.apache.commons" % "commons-lang3" % "3.4",
"org.scala-lang.modules" % "scala-xml_2.12" % "1.0.5",
"org.scala-lang.modules" % "scala-parser-combinators_2.12" % "1.0.4",
"org.ow2.asm" % "asm" % "5.0.4",
"org.jline" % "jline" % "3.10.0"
)
case Some((2, 11)) => List(
"io.github.classgraph" % "classgraph" % "4.8.78",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.1",
"org.scalacheck" %% "scalacheck" % "1.12.4" % "test",
"org.scalatest" %% "scalatest" % "2.2.6" % "test",
"junit" % "junit" % "4.12" % "test",
"com.novocode" % "junit-interface" % "0.11" % "test",
"org.apache.commons" % "commons-math3" % "3.2",
"org.apache.commons" % "commons-lang3" % "3.4",
"org.scala-lang.modules" %% "scala-xml" % "1.0.1",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1",
"org.ow2.asm" % "asm" % "5.0.4",
"org.jline" % "jline" % "3.10.0"
)
case _ => Nil
}
val javaCommand = TaskKey[String](
"java-command",
"Creates a java vm command for launching a process."
)
val javaCommandSetting = javaCommand := {
val dp = (dependencyClasspath in Compile).value
val jar = (artifactPath in(Compile, packageBin)).value
val testjar = (artifactPath in(Test, packageBin)).value
val pbc = (packageBin in Compile).value
val pbt = (packageBin in Test).value
val cp = dp.map(_.data) :+ jar :+ testjar
val javacommand = "java -Xmx2048m -Xms2048m -XX:+UseCondCardMark -verbose:gc -server -cp %s".format(
cp.mkString(File.pathSeparator)
)
javacommand
}
val runsuiteTask = InputKey[Unit](
"runsuite",
"Runs the benchmarking suite."
) := Def.inputTask {
val args = complete.DefaultParsers.spaceDelimited("<arg>").parsed
val jc = javaCommand.value
val javacommand = jc
val comm = javacommand + " " + "org.scalameter.Main" + " " + args.mkString(" ")
streams.map(_.log.info("Executing: " + comm))
import sys.process._
comm !
}
/* projects */
lazy val scalaMeterCore = Project(
"scalameter-core",
file("scalameter-core"),
settings = scalaMeterCoreSettings ++ releasePluginSettings
).enablePlugins(ReleasePlugin)
lazy val scalaMeter = Project(
"scalameter",
file("."),
settings = scalaMeterSettings ++ Seq(javaCommandSetting, runsuiteTask) ++ releasePluginSettings
) dependsOn (
scalaMeterCore
) aggregate (
scalaMeterCore
) enablePlugins (
ReleasePlugin
)
}