Skip to content

Commit

Permalink
Add release plug ins for publishing to Maven Central
Browse files Browse the repository at this point in the history
  • Loading branch information
robertberry-zz committed Aug 14, 2014
1 parent b44a4ae commit 14cc186
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 23 deletions.
74 changes: 51 additions & 23 deletions project/Build.scala
@@ -1,18 +1,59 @@
import java.util.jar._
import sbt._
import sbt.Keys._

import sbtrelease.ReleasePlugin._
import sbtrelease._
import ReleaseStateTransformations._
import xerial.sbt.Sonatype._
import com.typesafe.sbt.pgp._

object Build extends Build {

val commonSettings = Seq(
organization := "com.gu",
scalaVersion := "2.10.4",
crossScalaVersions := Seq("2.10.4", "2.11.2"),
version := "0.2-SNAPSHOT",
scalacOptions ++= Seq("-feature", "-deprecation", "-language:higherKinds", "-Xfatal-warnings")
)

val publishSettings = releaseSettings ++ sonatypeSettings ++ Seq(
scmInfo := Some(ScmInfo(
url("https://github.com/bmjames/json4s-zipper"),
"scm:git:git@github.com:bmjames/json4s-zipper.git"
)),
pomExtra := (
<url>https://github.com/bmjames/json4s-zipper</url>
<developers>
<developer>
<id>bmjames</id>
<name>Ben James</name>
<url>https://github.com/bmjames</url>
</developer>
</developers>
),
licenses := Seq(
"Apache V2" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")
),
ReleaseKeys.crossBuild := true,
ReleaseKeys.releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
ReleaseStep(
action = state => Project.extract(state).runTask(PgpKeys.publishSigned, state)._1,
enableCrossBuild = true
),
setNextVersion,
commitNextVersion,
ReleaseStep(state => Project.extract(state).runTask(SonatypeKeys.sonatypeReleaseAll, state)._1),
pushChanges
)
)

val scalazVersion = "7.1.0"
val scalacheckVersion = "1.11.0"
val scalatestVersion = "2.2.1"
Expand All @@ -23,20 +64,25 @@ object Build extends Build {
.settings(commonSettings ++ publishSettings: _*)
.settings(
name := "json-zipper-core",
description := "JSON Zipper core library",
libraryDependencies += "org.scalaz" %% "scalaz-core" % scalazVersion
)

val scalacheckBinding = Project("scalacheck-binding", file("scalacheck-binding"))
.dependsOn(core)
.settings(commonSettings ++ publishSettings: _*)
.settings(name := "json-zipper-scalacheck-binding")
.settings(libraryDependencies += "org.scalacheck" %% "scalacheck" % scalacheckVersion)
.settings(
name := "json-zipper-scalacheck-binding",
description := "JSON Zipper ScalaCheck binding",
libraryDependencies += "org.scalacheck" %% "scalacheck" % scalacheckVersion
)

val json4s = Project("json4s", file("json4s"))
.dependsOn(core, scalacheckBinding)
.settings(commonSettings ++ publishSettings: _*)
.settings(
name := "json-zipper-json4s",
description := "JSON Zipper Json4s binding",
libraryDependencies ++= Seq(
"org.json4s" %% "json4s-core" % json4sVersion,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % "test"
Expand All @@ -47,6 +93,7 @@ object Build extends Build {
.settings(commonSettings ++ publishSettings: _*)
.settings(
name := "json-zipper-play",
description := "JSON Zipper Play binding",
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/",
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % playVersion,
Expand All @@ -65,23 +112,4 @@ object Build extends Build {
val root = Project("root", file("."))
.settings(commonSettings: _*)
.aggregate(core, json4s, play, scalacheckBinding, test)

def publishSettings = Seq(
publishArtifact := true,
packageOptions <+= (version, name) map { (v, n) =>
Package.ManifestAttributes(
Attributes.Name.IMPLEMENTATION_VERSION -> v,
Attributes.Name.IMPLEMENTATION_TITLE -> n,
Attributes.Name.IMPLEMENTATION_VENDOR -> "guardian.co.uk"
)
},
publishTo <<= version { version: String =>
val publishType = if (version.endsWith("SNAPSHOT")) "snapshots" else "releases"
Some(Resolver.file(
"guardian github " + publishType,
file(System.getProperty("user.home") + "/guardian.github.com/maven/repo-" + publishType)
))
}
)

}
5 changes: 5 additions & 0 deletions project/plugins.sbt
@@ -0,0 +1,5 @@
addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.3")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.2")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1")
1 change: 1 addition & 0 deletions version.sbt
@@ -0,0 +1 @@
version in ThisBuild := "0.2-SNAPSHOT"

0 comments on commit 14cc186

Please sign in to comment.