|
| 1 | +import ReleaseTransformations._ |
| 2 | +import com.typesafe.sbt.SbtScalariform._ |
| 3 | +import com.typesafe.tools.mima.plugin.MimaKeys._ |
| 4 | +import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings |
| 5 | +import scala.collection.JavaConverters._ |
| 6 | +import scalariform.formatter.preferences._ |
| 7 | + |
| 8 | +val kryoVersion = "2.21" |
| 9 | +val bijectionVersion = "0.9.0" |
| 10 | +val algebirdVersion = "0.12.0" |
| 11 | + |
| 12 | +def isScala210x(scalaVersion: String) = scalaVersion match { |
| 13 | + case version if version startsWith "2.10" => true |
| 14 | + case _ => false |
| 15 | +} |
| 16 | + |
| 17 | +val sharedSettings = Project.defaultSettings ++ mimaDefaultSettings ++ scalariformSettings ++ Seq( |
| 18 | + organization := "com.twitter", |
| 19 | + scalaVersion := "2.10.5", |
| 20 | + crossScalaVersions := Seq("2.10.5", "2.11.7"), |
| 21 | + scalacOptions ++= Seq("-unchecked", "-deprecation"), |
| 22 | + ScalariformKeys.preferences := formattingPreferences, |
| 23 | + |
| 24 | + // Twitter Hadoop needs this, sorry 1.7 fans |
| 25 | + javacOptions ++= Seq("-target", "1.6", "-source", "1.6", "-Xlint:-options"), |
| 26 | + javacOptions in doc := Seq("-source", "1.6"), |
| 27 | + |
| 28 | + resolvers ++= Seq( |
| 29 | + Opts.resolver.sonatypeSnapshots, |
| 30 | + Opts.resolver.sonatypeReleases |
| 31 | + ), |
| 32 | + libraryDependencies ++= Seq( |
| 33 | + "org.scalacheck" %% "scalacheck" % "1.11.5" % "test", |
| 34 | + "org.scalatest" %% "scalatest" % "2.2.2" % "test", |
| 35 | + "com.esotericsoftware.kryo" % "kryo" % kryoVersion |
| 36 | + ), |
| 37 | + |
| 38 | + parallelExecution in Test := true, |
| 39 | + |
| 40 | + // Publishing options: |
| 41 | + releaseCrossBuild := true, |
| 42 | + releasePublishArtifactsAction := PgpKeys.publishSigned.value, |
| 43 | + publishMavenStyle := true, |
| 44 | + publishArtifact in Test := false, |
| 45 | + pomIncludeRepository := { x => false }, |
| 46 | + |
| 47 | + publishTo <<= version { v => |
| 48 | + Some( |
| 49 | + if (v.trim.toUpperCase.endsWith("SNAPSHOT")) |
| 50 | + Opts.resolver.sonatypeSnapshots |
| 51 | + else |
| 52 | + Opts.resolver.sonatypeStaging |
| 53 | + //"twttr" at "http://artifactory.local.twitter.com/libs-releases-local" |
| 54 | + ) |
| 55 | + }, |
| 56 | + pomExtra := ( |
| 57 | + <url>https://github.com/twitter/chill</url> |
| 58 | + <licenses> |
| 59 | + <license> |
| 60 | + <name>Apache 2</name> |
| 61 | + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> |
| 62 | + <distribution>repo</distribution> |
| 63 | + <comments>A business-friendly OSS license</comments> |
| 64 | + </license> |
| 65 | + </licenses> |
| 66 | + <scm> |
| 67 | + <url>git@github.com:twitter/chill.git</url> |
| 68 | + <connection>scm:git:git@github.com:twitter/chill.git</connection> |
| 69 | + </scm> |
| 70 | + <developers> |
| 71 | + <developer> |
| 72 | + <id>oscar</id> |
| 73 | + <name>Oscar Boykin</name> |
| 74 | + <url>http://twitter.com/posco</url> |
| 75 | + </developer> |
| 76 | + <developer> |
| 77 | + <id>sritchie</id> |
| 78 | + <name>Sam Ritchie</name> |
| 79 | + <url>http://twitter.com/sritchie</url> |
| 80 | + </developer> |
| 81 | + </developers>) |
| 82 | +) |
| 83 | + |
| 84 | +// Aggregated project |
| 85 | +lazy val chillAll = Project( |
| 86 | + id = "chill-all", |
| 87 | + base = file("."), |
| 88 | + settings = sharedSettings |
| 89 | +).settings( |
| 90 | + test := { }, |
| 91 | + publish := { }, |
| 92 | + publishLocal := { } |
| 93 | +).aggregate( |
| 94 | + chill, |
| 95 | + chillBijection, |
| 96 | + chillScrooge, |
| 97 | + chillStorm, |
| 98 | + chillJava, |
| 99 | + chillHadoop, |
| 100 | + chillThrift, |
| 101 | + chillProtobuf, |
| 102 | + chillAkka, |
| 103 | + chillAvro, |
| 104 | + chillAlgebird |
| 105 | + ) |
| 106 | + |
| 107 | +lazy val formattingPreferences = { |
| 108 | + import scalariform.formatter.preferences._ |
| 109 | + FormattingPreferences(). |
| 110 | + setPreference(AlignParameters, false). |
| 111 | + setPreference(PreserveSpaceBeforeArguments, true) |
| 112 | +} |
| 113 | + |
| 114 | +/** |
| 115 | + * This returns the youngest jar we released that is compatible |
| 116 | + * with the current. |
| 117 | + */ |
| 118 | +val unreleasedModules = Set[String]("akka") |
| 119 | +val javaOnly = Set[String]("storm", "java", "hadoop", "thrift", "protobuf") |
| 120 | + |
| 121 | +def youngestForwardCompatible(subProj: String) = |
| 122 | + Some(subProj) |
| 123 | + .filterNot(unreleasedModules.contains(_)) |
| 124 | + .map { s => |
| 125 | + val suffix = if (javaOnly.contains(s)) "" else "_2.10" |
| 126 | + "com.twitter" % ("chill-" + s + suffix) % "0.7.2" |
| 127 | + } |
| 128 | + |
| 129 | +def module(name: String) = { |
| 130 | + val id = "chill-%s".format(name) |
| 131 | + Project(id = id, base = file(id), settings = sharedSettings ++ Seq( |
| 132 | + Keys.name := id, |
| 133 | + previousArtifact := youngestForwardCompatible(name), |
| 134 | + // Disable cross publishing for java artifacts |
| 135 | + publishArtifact <<= (scalaVersion) { scalaVersion => |
| 136 | + if(javaOnly.contains(name) && scalaVersion.startsWith("2.11")) false else true |
| 137 | + } |
| 138 | + ) |
| 139 | + ) |
| 140 | +} |
| 141 | + |
| 142 | +// We usually do the pattern of having a core module, but we don't want to cause |
| 143 | +// pain for legacy deploys. With this, they can stay the same. |
| 144 | +lazy val chill = Project( |
| 145 | + id = "chill", |
| 146 | + base = file("chill-scala"), |
| 147 | + settings = sharedSettings |
| 148 | +).settings( |
| 149 | + name := "chill", |
| 150 | + previousArtifact := Some("com.twitter" % "chill_2.10" % "0.7.2") |
| 151 | +).dependsOn(chillJava) |
| 152 | + |
| 153 | +lazy val chillAkka = module("akka").settings( |
| 154 | + resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/", |
| 155 | + libraryDependencies ++= Seq( |
| 156 | + "com.typesafe" % "config" % "1.2.1", |
| 157 | + "com.typesafe.akka" %% "akka-actor" % "2.3.6" % "provided" |
| 158 | + ) |
| 159 | +).dependsOn(chill % "test->test;compile->compile") |
| 160 | + |
| 161 | +lazy val chillBijection = module("bijection").settings( |
| 162 | + libraryDependencies ++= Seq( |
| 163 | + "com.twitter" %% "bijection-core" % bijectionVersion |
| 164 | + ) |
| 165 | +).dependsOn(chill % "test->test;compile->compile") |
| 166 | + |
| 167 | +// This can only have java deps! |
| 168 | +lazy val chillJava = module("java").settings( |
| 169 | + crossPaths := false, |
| 170 | + autoScalaLibrary := false |
| 171 | +) |
| 172 | + |
| 173 | +// This can only have java deps! |
| 174 | +lazy val chillStorm = module("storm").settings( |
| 175 | + crossPaths := false, |
| 176 | + autoScalaLibrary := false, |
| 177 | + resolvers ++= Seq( |
| 178 | + "Clojars Repository" at "http://clojars.org/repo", |
| 179 | + "Conjars Repository" at "http://conjars.org/repo" |
| 180 | + ), |
| 181 | + libraryDependencies += "storm" % "storm" % "0.9.0-wip9" % "provided" |
| 182 | +).dependsOn(chillJava) |
| 183 | + |
| 184 | +// This can only have java deps! |
| 185 | +lazy val chillHadoop = module("hadoop").settings( |
| 186 | + crossPaths := false, |
| 187 | + autoScalaLibrary := false, |
| 188 | + libraryDependencies ++= Seq( |
| 189 | + "org.apache.hadoop" % "hadoop-core" % "0.20.2" % "provided", |
| 190 | + "org.slf4j" % "slf4j-api" % "1.6.6", |
| 191 | + "org.slf4j" % "slf4j-log4j12" % "1.6.6" % "provided" |
| 192 | + ) |
| 193 | +).dependsOn(chillJava) |
| 194 | + |
| 195 | +// This can only have java deps! |
| 196 | +lazy val chillThrift = module("thrift").settings( |
| 197 | + crossPaths := false, |
| 198 | + autoScalaLibrary := false, |
| 199 | + libraryDependencies ++= Seq( |
| 200 | + "org.apache.thrift" % "libthrift" % "0.6.1" % "provided" |
| 201 | + ) |
| 202 | +) |
| 203 | + |
| 204 | +lazy val chillScrooge = module("scrooge").settings( |
| 205 | + libraryDependencies ++= Seq( |
| 206 | + "org.apache.thrift" % "libthrift" % "0.6.1" exclude("junit", "junit"), |
| 207 | + "com.twitter" %% "scrooge-serializer" % "3.20.0" |
| 208 | + ) |
| 209 | +).dependsOn(chill % "test->test;compile->compile") |
| 210 | + |
| 211 | +// This can only have java deps! |
| 212 | +lazy val chillProtobuf = module("protobuf").settings( |
| 213 | + crossPaths := false, |
| 214 | + autoScalaLibrary := false, |
| 215 | + libraryDependencies ++= Seq( |
| 216 | + "com.google.protobuf" % "protobuf-java" % "2.3.0" % "provided" |
| 217 | + ) |
| 218 | +).dependsOn(chillJava) |
| 219 | + |
| 220 | +lazy val chillAvro = module("avro").settings( |
| 221 | + libraryDependencies ++= Seq( |
| 222 | + "com.twitter" %% "bijection-avro" % bijectionVersion, |
| 223 | + "junit" % "junit" % "4.5" % "test" |
| 224 | + ) |
| 225 | +).dependsOn(chill,chillJava, chillBijection) |
| 226 | + |
| 227 | +lazy val chillAlgebird = module("algebird").settings( |
| 228 | + libraryDependencies ++= Seq( |
| 229 | + "com.twitter" %% "algebird-core" % algebirdVersion |
| 230 | + ) |
| 231 | +).dependsOn(chill) |
0 commit comments