From 0bd6c5cf3bd4d9949ea23787bac45b9bf65f589c Mon Sep 17 00:00:00 2001 From: Alex Dean Date: Wed, 16 Jul 2014 12:18:04 +0100 Subject: [PATCH] Updated build process for local Maven publishing (fixes #72) Bumped SBT to 0.13.2 (fixes #73) Added support for Scala 2.10.4 and 2.11.1 (fixes #75) --- java-scala/CHANGELOG | 6 ++++++ java-scala/README.md | 6 +++--- java-scala/project/BuildSettings.scala | 13 ++++++++++-- java-scala/project/Dependencies.scala | 23 ++++++++++++++++++--- java-scala/project/RefererParserBuild.scala | 21 +++++++++++-------- java-scala/project/build.properties | 2 +- 6 files changed, 53 insertions(+), 18 deletions(-) diff --git a/java-scala/CHANGELOG b/java-scala/CHANGELOG index edbd6e85..0db11cc1 100644 --- a/java-scala/CHANGELOG +++ b/java-scala/CHANGELOG @@ -1,3 +1,9 @@ +Version 0.2.1 (2014-07-16) +-------------------------- +Updated build process for local Maven publishing (#72) +Bumped SBT to 0.13.2 (#73) +Added support for Scala 2.10.4 and 2.11.1 (#75) + Version 0.2.0 (2014-07-02) -------------------------- Added configurable list of domains which should count as "internal" (#18) diff --git a/java-scala/README.md b/java-scala/README.md index 1cfb163d..345b62b8 100644 --- a/java-scala/README.md +++ b/java-scala/README.md @@ -60,8 +60,8 @@ Then add into your project's `pom.xml`: ```xml com.snowplowanalytics - referer-parser - 0.3.0 + referer-parser_2.11 + 0.2.1 ``` @@ -118,7 +118,7 @@ Add this to your SBT config: val snowplowRepo = "SnowPlow Repo" at "http://maven.snplow.com/releases/" // Dependency -val refererParser = "com.snowplowanalytics" % "referer-parser" % "0.3.0" +val refererParser = "com.snowplowanalytics" %% "referer-parser" % "0.2.1" ``` ## Contributing diff --git a/java-scala/project/BuildSettings.scala b/java-scala/project/BuildSettings.scala index 2d40314f..65c5e63d 100644 --- a/java-scala/project/BuildSettings.scala +++ b/java-scala/project/BuildSettings.scala @@ -22,9 +22,10 @@ object BuildSettings { // Basic settings for our app lazy val basicSettings = Seq[Setting[_]]( organization := "com.snowplowanalytics", - version := "0.2.0", + version := "0.2.1", description := "Library for extracting marketing attribution data from referer URLs", scalaVersion := "2.9.1", + crossScalaVersions := Seq("2.9.1", "2.10.4", "2.11.1"), scalacOptions := Seq("-deprecation", "-encoding", "utf8"), resolvers ++= Dependencies.resolutionRepos ) @@ -32,7 +33,15 @@ object BuildSettings { // Publish settings // TODO: update with ivy credentials etc when we start using Nexus lazy val publishSettings = Seq[Setting[_]]( - crossPaths := false + // Enables publishing to maven repo + publishMavenStyle := true, + + publishTo <<= version { version => + val basePath = "target/repo/%s".format { + if (version.trim.endsWith("SNAPSHOT")) "snapshots/" else "releases/" + } + Some(Resolver.file("Local Maven repository", file(basePath)) transactional()) + } ) lazy val buildSettings = basicSettings ++ publishSettings diff --git a/java-scala/project/Dependencies.scala b/java-scala/project/Dependencies.scala index 77f63ede..2bda4c01 100644 --- a/java-scala/project/Dependencies.scala +++ b/java-scala/project/Dependencies.scala @@ -15,17 +15,21 @@ */ import sbt._ +import Keys._ object Dependencies { val resolutionRepos = Seq( - ScalaToolsSnapshots, "SnowPlow Analytics Maven repo" at "http://maven.snplow.com/releases/" ) object V { val yaml = "1.10" val http = "4.3.3" - val specs2 = "1.12.1" + object specs2 { + val _29 = "1.12.1" + val _210 = "1.14" + val _211 = "2.3.13" + } val scalaCheck = "1.10.0" val scalaUtil = "0.1.0" val junit = "4.11" @@ -36,7 +40,11 @@ object Dependencies { object Libraries { val yaml = "org.yaml" % "snakeyaml" % V.yaml val httpClient = "org.apache.httpcomponents" % "httpclient" % V.http - val specs2 = "org.specs2" %% "specs2" % V.specs2 % "test" + object specs2 { + val _29 = "org.specs2" %% "specs2" % V.specs2._29 % "test" + val _210 = "org.specs2" %% "specs2" % V.specs2._210 % "test" + val _211 = "org.specs2" %% "specs2" % V.specs2._211 % "test" + } val junit = "junit" % "junit" % V.junit % "test" val json = "org.json" % "json" % V.json % "test" val scalaCheck = "org.scalacheck" %% "scalacheck" % V.scalaCheck % "test" @@ -44,4 +52,13 @@ object Dependencies { val json4sJackson = "org.json4s" %% "json4s-jackson" % V.json4s % "test" val json4sScalaz = "org.json4s" %% "json4s-scalaz" % V.json4s % "test" } + + def onVersion[A](all: Seq[A] = Seq(), on29: => Seq[A] = Seq(), on210: => Seq[A] = Seq(), on211: => Seq[A] = Seq()) = + scalaVersion(v => all ++ (if (v.contains("2.9.")) { + on29 + } else if (v.contains("2.10.")) { + on210 + } else { + on211 + })) } diff --git a/java-scala/project/RefererParserBuild.scala b/java-scala/project/RefererParserBuild.scala index 20164908..6a4e8cf3 100644 --- a/java-scala/project/RefererParserBuild.scala +++ b/java-scala/project/RefererParserBuild.scala @@ -31,15 +31,18 @@ object RefererParserBuild extends Build { lazy val project = Project("referer-parser", file(".")) .settings(buildSettings: _*) .settings( - libraryDependencies ++= Seq( - Libraries.yaml, - Libraries.httpClient, - Libraries.specs2, - Libraries.scalaCheck, - Libraries.scalaUtil, - Libraries.junit, - Libraries.json, - Libraries.json4sJackson + libraryDependencies <++= Dependencies.onVersion( + all = Seq( + Libraries.yaml, + Libraries.httpClient, + Libraries.scalaCheck, + Libraries.scalaUtil, + Libraries.junit, + Libraries.json, + Libraries.json4sJackson), + on29 = Seq(Libraries.specs2._29), + on210 = Seq(Libraries.specs2._210), + on211 = Seq(Libraries.specs2._211) ) ) } diff --git a/java-scala/project/build.properties b/java-scala/project/build.properties index d4287112..8ac605a3 100644 --- a/java-scala/project/build.properties +++ b/java-scala/project/build.properties @@ -1 +1 @@ -sbt.version=0.11.3 +sbt.version=0.13.2