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

Commit

Permalink
Merge pull request #30 from ktonga/scalaz-version-qualifier
Browse files Browse the repository at this point in the history
Encode Scalaz compatibility in the build version
  • Loading branch information
timperrett committed May 3, 2016
2 parents d34f5e7 + 5e70a15 commit 5c34d98
Showing 1 changed file with 15 additions and 13 deletions.
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"
}
)
}

0 comments on commit 5c34d98

Please sign in to comment.