This repository has been archived by the owner on Mar 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe0cfa5
commit 3878679
Showing
9 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
organization := "io.verizon.build" | ||
|
||
name := "sbt-scalaz" | ||
|
||
scalacOptions ++= Seq("-deprecation", "-feature") | ||
|
||
sbtPlugin := true | ||
|
||
ScriptedPlugin.scriptedSettings | ||
|
||
scriptedLaunchOpts ++= Seq( | ||
"-Xmx1024M", | ||
"-Dplugin.version=" + version.value, | ||
"-Dscripted=true") | ||
|
||
scriptedBufferLog := false | ||
|
||
fork := true | ||
|
||
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")) | ||
|
||
homepage := Some(url("https://github.com/verizon/sbt-scalaz")) | ||
|
||
scmInfo := Some(ScmInfo(url("https://github.com/verizon/sbt-scalaz"), | ||
"git@github.com:verizon/sbt-scalaz.git")) | ||
|
||
// To sync with Maven central, you need to supply the following information: | ||
pomExtra in Global := { | ||
<developers> | ||
<developer> | ||
<id>rossabaker</id> | ||
<name>Ross A. Baker</name> | ||
<url>http://rossabaker.com/</url> | ||
</developer> | ||
</developers> | ||
} | ||
|
||
sonatypeProfileName := "io.verizon" | ||
|
||
pomPostProcess := { identity } | ||
|
||
addCommandAlias("validate", ";test;scripted") | ||
|
||
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") | ||
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") | ||
|
||
addCommandAlias("validate", ";test;scripted") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=0.13.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value | ||
|
||
addSbtPlugin("io.verizon.build" % "sbt-rig" % "1.3.27") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package verizon.build | ||
|
||
import sbt._, Keys._ | ||
|
||
object ScalazPlugin extends AutoPlugin { | ||
object autoImport { | ||
val scalazVersion = settingKey[String]("scalaz version") | ||
|
||
val scalazVersionRewriter = settingKey[(String, String) => String]("adjust the version based on a scalaz version") | ||
} | ||
|
||
import autoImport._ | ||
|
||
override def trigger = allRequirements | ||
|
||
override lazy val projectSettings = Seq( | ||
scalazVersion := sys.env.get("SCALAZ_VERSION").getOrElse("7.2.7"), | ||
scalazVersionRewriter := scalazBinaryVersionInQualifier, | ||
version := scalazVersionRewriter.value(version.value, scalazVersion.value) | ||
) | ||
|
||
val scalazBinaryVersionInQualifier = { (version: String, scalazVersion: String) => | ||
version match { | ||
case VersionNumber(numbers, tags, extras) => | ||
val qualifier = scalazVersion match { | ||
case VersionNumber(Seq(zMajor, zMinor, _*), _, _) => | ||
s"scalaz-$zMajor.$zMinor" | ||
case _ => | ||
s"scalaz-$scalazVersion" | ||
} | ||
numbers.mkString(".") + (qualifier +: tags).mkString("-", "-", "") + extras.mkString("") | ||
case _ => | ||
// Can't determine scalaz binary compatibility. *shrug* | ||
s"${version}-scalaz-${scalazVersion}" | ||
} | ||
} | ||
|
||
/** | ||
* This convention is prevalent in the community (scalaz-stream, | ||
* http4s < 0.16, argonaut-6.1), but not recommended as it breaks | ||
* semantic versioning. | ||
*/ | ||
val scalazSevenTwoSuffixA = { (version: String, scalazVersion: String) => | ||
VersionNumber(scalazVersion).numbers match { | ||
case Seq(7, 2, _*) => | ||
version match { | ||
case VersionNumber(numbers, tags, extras) => | ||
numbers.mkString(".") + "a" + (tags match { | ||
case Seq() => "" | ||
case ts => ts.mkString("-", "-", "") | ||
}) + extras.mkString("") | ||
} | ||
case _ => | ||
version | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import verizon.build.ScalazPlugin | ||
|
||
version in ThisBuild := "0.1.0" | ||
|
||
TaskKey[Unit]("check") := { | ||
val expectedVersion = "0.1.0-scalaz-7.2" | ||
if (version.value != expectedVersion) | ||
sys.error(s"""Expected version "${expectedVersion}", got "${version.value}""") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
val pluginVersion = System.getProperty("plugin.version") | ||
if(pluginVersion == null) | ||
throw new RuntimeException("""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
else addSbtPlugin("io.verizon.build" % "sbt-scalaz" % pluginVersion) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
> check | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package verizon.build | ||
|
||
import org.scalatest.{FlatSpec, Matchers} | ||
import ScalazPlugin._ | ||
|
||
class ScalazPluginSpec extends FlatSpec with Matchers { | ||
behavior of "scalazBinaryVersionInQualifier" | ||
|
||
it should "put the scalaz binary version after the version" in { | ||
scalazBinaryVersionInQualifier("0.1.0", "7.2.7") should be ("0.1.0-scalaz-7.2") | ||
} | ||
|
||
it should "put the scalaz binary version before SNAPSHOT" in { | ||
scalazBinaryVersionInQualifier("0.1.0-SNAPSHOT", "7.2.7") should be ("0.1.0-scalaz-7.2-SNAPSHOT") | ||
} | ||
|
||
behavior of "scalazSevenTwoSuffixA" | ||
|
||
it should "not mark scalaz-7.1" in { | ||
scalazSevenTwoSuffixA("0.1.0", "7.1.11") should be ("0.1.0") | ||
} | ||
|
||
it should "put the 'a' suffix after the version" in { | ||
scalazSevenTwoSuffixA("0.1.0", "7.2.7") should be ("0.1.0a") | ||
} | ||
|
||
it should "put the 'a' suffix before SNAPSHOT" in { | ||
scalazSevenTwoSuffixA("0.1.0-SNAPSHOT", "7.2.7") should be ("0.1.0a-SNAPSHOT") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version in ThisBuild := "0.1.0-SNAPSHOT" |