-
Notifications
You must be signed in to change notification settings - Fork 343
/
Build.scala
188 lines (157 loc) · 6.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
package algebird
import sbt._
import Keys._
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
import com.typesafe.tools.mima.plugin.MimaKeys.previousArtifact
import scalariform.formatter.preferences._
import com.typesafe.sbt.SbtScalariform._
import pl.project13.scala.sbt.JmhPlugin
object AlgebirdBuild extends Build {
val paradiseVersion = "2.0.1"
val quasiquotesVersion = "2.0.1"
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 _ => sys.error("unknown error")
}
def isScala210x(scalaVersion: String) = scalaBinaryVersion(scalaVersion) == "2.10"
val sharedSettings = Project.defaultSettings ++ scalariformSettings ++ Seq(
organization := "com.twitter",
scalaVersion := "2.10.5",
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:
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { x => false },
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>git@github.com:twitter/algebird.git</url>
<connection>scm:git:git@github.com: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 unreleasedModules = Set[String]()
def youngestForwardCompatible(subProj: String) =
Some(subProj)
.filterNot(unreleasedModules.contains(_))
.map { s => "com.twitter" % ("algebird-" + s + "_2.10") % "0.11.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" % "0.8.0")
).dependsOn(algebirdCore, algebirdUtil, algebirdTest % "test->compile").enablePlugins(JmhPlugin)
lazy val algebirdUtil = module("util").settings(
libraryDependencies += "com.twitter" %% "util-core" % "6.20.0"
).dependsOn(algebirdCore, algebirdTest % "test->test")
lazy val algebirdBijection = module("bijection").settings(
libraryDependencies += "com.twitter" %% "bijection-core" % "0.8.0"
).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")
}