Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Encode Scalaz compatibility in the build version #30

Merged
merged 1 commit into from
May 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions project/common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ object common {
testSettings ++
customSettings

val scalaTestVersion = SettingKey[String]("scalatest version")
val scalaCheckVersion = SettingKey[String]("scalacheck version")
val scalazStreamVersion = SettingKey[String]("scalaz stream version")
val scalaTestVersion = settingKey[String]("scalatest version")
val scalaCheckVersion = settingKey[String]("scalacheck version")
val scalazStreamVersion = settingKey[String]("scalaz stream version")

def testSettings = Seq(
scalaTestVersion := "2.2.5",
Expand All @@ -42,13 +42,17 @@ object common {
bintrayPackage := "knobs"
)

def withoutSnapshot(ver: Version) =
if(ver.qualifier.exists(_ == "-SNAPSHOT")) ver.withoutQualifier
else ver.copy(qualifier = ver.qualifier.map(_.replaceAll("-SNAPSHOT", "")))

def releaseSettings = Seq(
releaseCrossBuild := true,
releaseVersion := { ver =>
sys.env.get("TRAVIS_BUILD_NUMBER").orElse(sys.env.get("BUILD_NUMBER"))
.map(s => try Option(s.toInt) catch { case _: NumberFormatException => Option.empty[Int] })
.flatMap(ci => Version(ver).map(_.withoutQualifier.copy(bugfix = ci).string))
.orElse(Version(ver).map(_.withoutQualifier.string))
.flatMap(ci => Version(ver).map(v => withoutSnapshot(v).copy(bugfix = ci).string))
.orElse(Version(ver).map(v => withoutSnapshot(v).string))
.getOrElse(versionFormatError)
},
releaseProcess := Seq(
Expand Down Expand Up @@ -103,14 +107,12 @@ object common {
sys.env.get("SCALAZ_STREAM_VERSION").getOrElse("0.7.3a")
},
unmanagedSourceDirectories in Compile += (sourceDirectory in Compile).value / s"scalaz-stream-${scalazStreamVersion.value.take(3)}",
artifactName := { (scalaVersion: ScalaVersion, module: ModuleID, artifact: Artifact) =>
val classifierStr = artifact.classifier.fold("")("-"+_)
val cross = CrossVersion(module.crossVersion, scalaVersion.full, scalaVersion.binary)
val base = CrossVersion.applyCross(artifact.name, cross)
val qualifier =
if(scalazStreamVersion.value.startsWith("0.7")) "scalaz71"
else "scalaz72"
base + "_" + qualifier + "-" + releaseVersion.value(version.value) + classifierStr + "." + artifact.extension
version := {
val suffix = if(scalazStreamVersion.value.startsWith("0.7")) "" else "a"
val versionValue = version.value
if(versionValue.endsWith("-SNAPSHOT"))
versionValue.replaceAll("-SNAPSHOT", s"$suffix-SNAPSHOT")
else s"$versionValue$suffix"
}
)
}