forked from twitter/algebird
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
202 lines (173 loc) · 6.53 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
import ReleaseTransformations._
import algebird._
import com.typesafe.sbt.SbtScalariform._
import com.typesafe.tools.mima.plugin.MimaKeys.previousArtifact
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
import pl.project13.scala.sbt.JmhPlugin
import scalariform.formatter.preferences._
val paradiseVersion = "2.0.1"
val quasiquotesVersion = "2.0.1"
val bijectionVersion = "0.9.0"
val utilVersion = "6.20.0"
def scalaBinaryVersion(scalaVersion: String) = scalaVersion match {
case version if version startsWith "2.10" => "2.10"
case version if version startsWith "2.11" => "2.11"
case version if version startsWith "2.12" => "2.12"
case _ => sys.error("unknown error")
}
def isScala210x(scalaVersion: String) = scalaBinaryVersion(scalaVersion) == "2.10"
val sharedSettings = Project.defaultSettings ++ scalariformSettings ++ Seq(
organization := "com.twitter",
scalaVersion := "2.11.7",
crossScalaVersions := Seq("2.10.5", "2.11.7"),
ScalariformKeys.preferences := formattingPreferences,
resolvers ++= Seq(
"snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"releases" at "http://oss.sonatype.org/content/repositories/releases"
),
parallelExecution in Test := true,
javacOptions ++= Seq("-target", "1.6", "-source", "1.6"),
scalacOptions ++= Seq("-unchecked", "-deprecation", "-optimize", "-Xlint", "-language:implicitConversions", "-language:higherKinds", "-language:existentials"),
scalacOptions <++= (scalaVersion) map { sv =>
if (sv startsWith "2.10")
Seq("-Xdivergence211")
else
Seq()
},
javacOptions ++= Seq("-target", "1.6", "-source", "1.6"),
libraryDependencies += "junit" % "junit" % "4.11" % "test",
// Publishing options:
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseVersionBump := sbtrelease.Version.Bump.Minor, // need to tweak based on mima results
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { x => false },
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
pushChanges),
publishTo <<= version { v =>
Some(
if (v.trim.endsWith("SNAPSHOT"))
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
)
},
pomExtra := (
<url>https://github.com/twitter/algebird</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<scm>
<url>[email protected]:twitter/algebird.git</url>
<connection>scm:git:[email protected]:twitter/algebird.git</connection>
</scm>
<developers>
<developer>
<id>oscar</id>
<name>Oscar Boykin</name>
<url>http://twitter.com/posco</url>
</developer>
<developer>
<id>sritchie</id>
<name>Sam Ritchie</name>
<url>http://twitter.com/sritchie</url>
</developer>
</developers>)
) ++ mimaDefaultSettings
lazy val formattingPreferences = {
import scalariform.formatter.preferences._
FormattingPreferences().
setPreference(AlignParameters, false).
setPreference(PreserveSpaceBeforeArguments, true)
}
/**
* This returns the youngest jar we released that is compatible with
* the current.
*/
val noBinaryCompatCheck = Set[String]("benchmark", "caliper")
def youngestForwardCompatible(subProj: String) =
Some(subProj)
.filterNot(noBinaryCompatCheck.contains(_))
.map { s => "com.twitter" %% ("algebird-" + s) % "0.12.0" }
lazy val algebird = Project(
id = "algebird",
base = file("."),
settings = sharedSettings ++ DocGen.publishSettings
).settings(
test := { },
publish := { }, // skip publishing for this root project.
publishLocal := { }
).aggregate(
algebirdTest,
algebirdCore,
algebirdUtil,
algebirdBijection,
algebirdBenchmark,
algebirdSpark
)
def module(name: String) = {
val id = "algebird-%s".format(name)
Project(id = id, base = file(id), settings = sharedSettings ++ Seq(
Keys.name := id,
previousArtifact := youngestForwardCompatible(name))
)
}
lazy val algebirdCore = module("core").settings(
test := { }, // All tests reside in algebirdTest
initialCommands := """
import com.twitter.algebird._
""".stripMargin('|'),
libraryDependencies <++= (scalaVersion) { scalaVersion =>
Seq("com.googlecode.javaewah" % "JavaEWAH" % "0.6.6",
"org.scala-lang" % "scala-reflect" % scalaVersion) ++ {
if (isScala210x(scalaVersion))
Seq("org.scalamacros" %% "quasiquotes" % quasiquotesVersion)
else
Seq()
}
},
sourceGenerators in Compile <+= sourceManaged in Compile map { outDir: File =>
GenTupleAggregators.gen(outDir)
}, addCompilerPlugin("org.scalamacros" % "paradise" % paradiseVersion cross CrossVersion.full)
)
lazy val algebirdTest = module("test").settings(
testOptions in Test ++= Seq(Tests.Argument(TestFrameworks.ScalaCheck, "-verbosity", "4")),
libraryDependencies <++= (scalaVersion) { scalaVersion =>
Seq("org.scalacheck" %% "scalacheck" % "1.12.5",
"org.scalatest" %% "scalatest" % "2.2.4") ++ {
if (isScala210x(scalaVersion))
Seq("org.scalamacros" %% "quasiquotes" % quasiquotesVersion)
else
Seq()
}
}, addCompilerPlugin("org.scalamacros" % "paradise" % paradiseVersion cross CrossVersion.full)
).dependsOn(algebirdCore)
lazy val algebirdBenchmark = module("benchmark").settings(JmhPlugin.projectSettings:_*).settings(
libraryDependencies ++= Seq("com.twitter" %% "bijection-core" % bijectionVersion)
).dependsOn(algebirdCore, algebirdUtil, algebirdTest % "test->compile").enablePlugins(JmhPlugin)
lazy val algebirdUtil = module("util").settings(
libraryDependencies += "com.twitter" %% "util-core" % utilVersion
).dependsOn(algebirdCore, algebirdTest % "test->test")
lazy val algebirdBijection = module("bijection").settings(
libraryDependencies += "com.twitter" %% "bijection-core" % bijectionVersion
).dependsOn(algebirdCore, algebirdTest % "test->test")
lazy val algebirdSpark = module("spark").settings(
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.3.0" % "provided"
).dependsOn(algebirdCore, algebirdTest % "test->test")