Skip to content

Commit

Permalink
Revert "Scala 2.12 support (closes #153)" (#166)
Browse files Browse the repository at this point in the history
This reverts commit 631683d.
  • Loading branch information
BenFradet authored Nov 3, 2017
1 parent 631683d commit 5626967
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 34 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: scala
before_script: "cd java-scala"
scala:
- 2.12.4
- 2.9.1
jdk:
- oraclejdk8
- openjdk8
- oraclejdk7
- openjdk6
- openjdk7
2 changes: 0 additions & 2 deletions java-scala/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ lib_managed/
src_managed/
project/boot/
project/plugins/project/
project/project
project/target
23 changes: 0 additions & 23 deletions java-scala/build.sbt

This file was deleted.

48 changes: 48 additions & 0 deletions java-scala/project/BuildSettings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright 2012-2013 Snowplow Analytics Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import sbt._
import Keys._

object BuildSettings {

// Basic settings for our app
lazy val basicSettings = Seq[Setting[_]](
organization := "com.snowplowanalytics",
version := "0.3.0",
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
)

// Publish settings
// TODO: update with ivy credentials etc when we start using Nexus
lazy val publishSettings = Seq[Setting[_]](
// 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
}
64 changes: 64 additions & 0 deletions java-scala/project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright 2012-2013 Snowplow Analytics Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import sbt._
import Keys._

object Dependencies {
val resolutionRepos = Seq(
"SnowPlow Analytics Maven repo" at "http://maven.snplow.com/releases/"
)

object V {
val yaml = "1.10"
val http = "4.3.3"
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"
val json = "20140107"
val json4s = "3.2.9"
}

object Libraries {
val yaml = "org.yaml" % "snakeyaml" % V.yaml
val httpClient = "org.apache.httpcomponents" % "httpclient" % V.http
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"
val scalaUtil = "com.snowplowanalytics" % "scala-util" % V.scalaUtil % "test"
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
}))
}
48 changes: 48 additions & 0 deletions java-scala/project/RefererParserBuild.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright 2012-2013 Snowplow Analytics Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import sbt._
import Keys._

object RefererParserBuild extends Build {

import Dependencies._
import BuildSettings._

// Configure prompt to show current project
override lazy val settings = super.settings :+ {
shellPrompt := { s => Project.extract(s).currentProject.id + " > " }
}

// Define our project, with basic project information and library dependencies
lazy val project = Project("referer-parser", file("."))
.settings(buildSettings: _*)
.settings(
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)
)
)
}
2 changes: 1 addition & 1 deletion java-scala/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.0.2
sbt.version=0.13.2
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ class JsonParseTest extends Specification {

val internalDomains = List("www.subdomain1.snowplowanalytics.com", "www.subdomain2.snowplowanalytics.com")

def getString(node: JValue, name: String): String =
def getString(node: JValue, name: String): String =
(node \ name) match {
case JString(s) => s
case _ => throw new Exception("The value of field '%s' in referer-tests.json is not a string - this should never happen".format(name))
}

"parse" should {
"extract the expected details from referer with spec" in {
for (test <- testJson) yield {

Parser.parse(getString(test, "uri"), pageHost, internalDomains) shouldEqual
for (test <- testJson) {

"extract the expected details from referer with spec '%s'".format(getString(test, "spec")) in {

Parser.parse(getString(test, "uri"), pageHost, internalDomains) must_==
Some(Referer(
Medium.withName(getString(test, "medium")),
(test \ "source") match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ class ParseFuzzTest extends Specification with ScalaCheck {
"The parse function should work for any pair of referer and page Strings" ! e1

def e1 =
prop { (refererUri: String, pageUri: String) => Parser.parse(refererUri, pageUri) must beAnInstanceOf[Parser.MaybeReferer] }
check { (refererUri: String, pageUri: String) => Parser.parse(refererUri, pageUri) must beAnInstanceOf[Parser.MaybeReferer] }
}

0 comments on commit 5626967

Please sign in to comment.