package blended.mgmt.rest.internal

import scala.collection.JavaConverters._
import scala.util.Failure
import scala.util.Success

import blended.persistence.PersistenceService
import blended.updater.config.Mapper
import blended.updater.config.RemoteContainerState
import blended.util.logging.Logger

class RemoteContainerStatePersistor(persistenceService: PersistenceService) {

  private[this] val log = Logger[RemoteContainerStatePersistor]

  val pClass = "RemoteContainerState"

  def findAll(): List[RemoteContainerState] = {
    val result = persistenceService.findAll(pClass)
    log.debug(s"loaded ${result.size} entries from db")
    result.toList.flatMap { s =>
      Mapper.unmapRemoteContainerState(s) match {
        case Success(s) => List(s)
        case Failure(e) =>
          log.warn(e)(s"Could not create RemoteContainerState from persisted map (ignoring this entry): ${s}")
          List()
      }
    }
  }

  def updateState(state: RemoteContainerState): Unit = {
    log.debug(s"About to persist remote container state: ${state}")
    val deleteCount = persistenceService.deleteByExample(pClass, Map("containerInfo.containerId" -> state.containerInfo.containerId).asJava)
    log.debug(s"deleted ${deleteCount} old entries")
    val entry = persistenceService.persist(pClass, Mapper.mapRemoteContainerState(state))
    log.debug(s"persisted 1 new entry: ${entry}")
  }

}

package blended.mgmt.rest.internal

import scala.collection.JavaConverters._
import scala.util.Failure
import scala.util.Success

import blended.persistence.PersistenceService
import blended.updater.config.Mapper
import blended.updater.config.RemoteContainerState
import blended.util.logging.Logger

class RemoteContainerStatePersistor(persistenceService: PersistenceService) {

  private[this] val log = Logger[RemoteContainerStatePersistor]

  val pClass = "RemoteContainerState"

  def findAll(): List[RemoteContainerState] = {
    val result = persistenceService.findAll(pClass)
    log.debug(s"loaded ${result.size} entries from db")
    result.toList.flatMap { s =>
      Mapper.unmapRemoteContainerState(s) match {
        case Success(s) => List(s)
        case Failure(e) =>
          log.warn(e)(s"Could not create RemoteContainerState from persisted map (ignoring this entry): ${s}")
          List()
      }
    }
  }

  def updateState(state: RemoteContainerState): Unit = {
    log.debug(s"About to persist remote container state: ${state}")
    val deleteCount = persistenceService.deleteByExample(pClass, Map(
      "containerInfo" -> Map(
        "containerId" -> state.containerInfo.containerId
      ).asJava
    ).asJava)
    log.debug(s"deleted ${deleteCount} old entries")
    val entry = persistenceService.persist(pClass, Mapper.mapRemoteContainerState(state))
    log.debug(s"persisted 1 new entry: ${entry}")
  }

}

Make data structure compatible to persistence API


package uk.ac.wellcome.display.models.v1

import com.fasterxml.jackson.annotation.JsonProperty
import io.swagger.annotations.{ApiModel, ApiModelProperty}
import uk.ac.wellcome.models.work.internal.License

@ApiModel(
  value = "License",
  description =
    "The specific license under which the work in question is released to the public - for example, one of the forms of Creative Commons - if it is a precise license to which a link can be made."
)
case class DisplayLicenseV1(
  @ApiModelProperty(
    value =
      "A type of license under which the work in question is released to the public.",
    allowableValues = "CC-BY, CC-BY-NC, CC-BY-NC-ND, CC-0, PDM"
  ) licenseType: String,
  @ApiModelProperty(
    value = "The title or other short name of a license"
  ) label: String,
  @ApiModelProperty(
    value = "URL to the full text of a license"
  ) url: String
) {
  @ApiModelProperty(readOnly = true, value = "A type of thing")
  @JsonProperty("type") val ontologyType: String = "License"
}

case object DisplayLicenseV1 {
  def apply(license: License): DisplayLicenseV1 = DisplayLicenseV1(
    licenseType = license.id.toUpperCase,
    label = license.label,
    url = license.url
  )
}

package uk.ac.wellcome.display.models.v1

import com.fasterxml.jackson.annotation.JsonProperty
import io.swagger.annotations.{ApiModel, ApiModelProperty}
import uk.ac.wellcome.models.work.internal.License

@ApiModel(
  value = "License",
  description =
    "The specific license under which the work in question is released to the public - for example, one of the forms of Creative Commons - if it is a precise license to which a link can be made."
)
case class DisplayLicenseV1(
  @ApiModelProperty(
    value =
      "A type of license under which the work in question is released to the public.",
    allowableValues = "CC-BY, CC-BY-NC, CC-BY-NC-ND, CC-0, PDM"
  ) licenseType: String,
  @ApiModelProperty(
    value = "The title or other short name of a license"
  ) label: String,
  @ApiModelProperty(
    value = "URL to the full text of a license"
  ) url: String
) {
  @ApiModelProperty(readOnly = true, value = "A type of thing")
  @JsonProperty("type") val ontologyType: String = "License"
}

case object DisplayLicenseV1 {
  def apply(license: License): DisplayLicenseV1 = DisplayLicenseV1(
    // The old model for License had an uppercase "licenseType" field,
    // e.g. "CC-BY" or "PDM".
    //
    // The current model uses lowercase IDs.  To preserve the V1 API,
    // we uppercase the IDs before presenting them.
    licenseType = license.id.toUpperCase,
    label = license.label,
    url = license.url
  )
}

Add a comment explaining the uppercasing


import scala.io._
import scala.actors._
import Actor._

object PageLoader {
  def getPageSize(url: String) = Source.fromURL(url).mkString.length
}

val urls = List(
  "http://www.amazon.com",
  "http://www.twitter.com",
  "http://www.google.com",
  "http://www.cnn.com")

def timeMethod(method: () => Unit) = {
  val start = System.nanoTime
  method()
  val end = System.nanoTime
  println("Method took " + (end - start) / 1000000000.0 + " seconds.")
}

def getPagesSequentially() = {
  for (url <- urls) {
    println("Size for " + url + ": " + PageLoader.getPageSize(url))
  }
}

def getPagesConcurrently() = {
  val caller = self

  for (url <- urls) {
    actor { caller ! (url, PageLoader.getPageSize(url)) }
  }

  for (i <- 1 to urls.size) {
    receive {
      case (url, size) =>
        println("Size for " + url + ": " + size)
    }
  }
}

println("Sequential run:")
timeMethod { getPagesSequentially }

println("Concurrent run:")
timeMethod { getPagesConcurrently }

import scala.io._
import scala.actors._
import Actor._

object PageLoader {
  def getPageSize(url: String) = Source.fromURL(url, "latin1").mkString.length
}

val urls = List(
  "http://www.amazon.com",
  "http://www.twitter.com",
  "http://www.google.com",
  "http://www.cnn.com")

def timeMethod(method: () => Unit) = {
  val start = System.nanoTime
  method()
  val end = System.nanoTime
  println("Method took " + (end - start) / 1000000000.0 + " seconds.")
}

def getPagesSequentially() = {
  for (url <- urls) {
    println("Size for " + url + ": " + PageLoader.getPageSize(url))
  }
}

def getPagesConcurrently() = {
  val caller = self

  for (url <- urls) {
    actor { caller ! (url, PageLoader.getPageSize(url)) }
  }

  for (i <- 1 to urls.size) {
    receive {
      case (url, size) =>
        println("Size for " + url + ": " + size)
    }
  }
}

println("Sequential run:")
timeMethod { getPagesSequentially }

println("Concurrent run:")
timeMethod { getPagesConcurrently }

Set to latin1 encoding (8-bit, single-byte) to fix


import sys.process._
import java.io.IOException

object trafficTest {

  def main(args:Array[String]) {

    val MAX_THREAD = args(0).toInt;
    var totalTime:Long = 0;
    val now = System.nanoTime;

    def readURL()= {
      //val url1 = "https://www.yahoo.com/";
      val url1 ="http://10.4.17.63:8081/chart1.html";
      try{
       io.Source.fromURL(url1)
      } catch{
          case e: Exception => { e.printStackTrace(); e.toString() }
      } finally {
         val processTime = (System.nanoTime - now) /1000/1000; //million seconds
         totalTime = List(totalTime,processTime).max;
         println(" Total Process Time: %d ms".format(totalTime));
      }
    }

    // get URL cocurrently
    for (i <- 1 to  MAX_THREAD ) {
        val thread = new Thread {
            override def run {
                readURL();
            }
        }
        thread.start
        //Thread.sleep(50) // slow the loop down a bit
    }
  }
}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.duration._

object trafficTest {

 def main(args:Array[String]) {
   val test_count_concurrent =  if (args.length > 0) args(0).toInt else 5

   def readURL(url:String) = {
    //Access indicated URL, and return the process time in million seconds.
    //If there is some error/exception,e.g. no response error, return -1 as error.
    //Get the Content with io.Source package
    val start = System.nanoTime;io.Source.fromURL(url);val process_time = (System.nanoTime - start) /1000/1000 //million seconds
    process_time
   }

    val urls_sample = Seq("http://openvswitch.org/","http://www.alliedtelesis.com","http://www.alliedtelesis.com");
    val urls = List.fill(test_count_concurrent)(urls_sample).flatten.take(test_count_concurrent) // get the test urls
    println(urls)
    val seq_read_urls = urls.map(url => Future(readURL(url)))
    //val seq_read_urls = List (Future(readURL("https://www.yahoo.com/")) ,Future(readURL("http://www.alliedtelesis.com")))
    val read_url_tests = Future sequence seq_read_urls
    val process_times = concurrent.Await.result(read_url_tests, 10.minutes)

    println("Test Count:" + process_times.length)
    println("Min:" + process_times.min +"ms")
    println("Avg:" + process_times.sum / process_times.length +"ms")
    println("Max:" + process_times.max +"ms")
    println("Total:" + process_times.sum +"ms")

}

}

Change the code into pure scala implementation. Use Future for concurrent test


package net.ceedubs.ficus

import com.typesafe.config.ConfigFactory
import FicusConfig.{ booleanValueReader, optionValueReader, toFicusConfig }

class FicusConfigSpec extends Spec { def is =
  "A Ficus config should" ^
    "be implicitly converted from a Typesafe config" ! implicitlyConverted ^
    "read a value with a value reader" ! readAValue ^
    "get an existing value as a Some" + getAsSome ^
    "get a missing value as a None" + getAsNone ^
    "accept a CongigKey and return the appropriate type" ! acceptAConfigKey

  def implicitlyConverted = {
    val cfg = ConfigFactory.parseString("myValue = true")
    cfg.as[Boolean]("myValue") must beTrue
  }

  def readAValue = prop { b: Boolean =>
    val cfg = ConfigFactory.parseString(s"myValue = $b")
    cfg.as[Boolean]("myValue") must beEqualTo(b)
  }

  def getAsSome = prop { b: Boolean =>
    val cfg = ConfigFactory.parseString(s"myValue = $b")
    cfg.getAs[Boolean]("myValue") must beSome(b)
  }

  def getAsNone = {
    val cfg = ConfigFactory.parseString("myValue = true")
    cfg.getAs[Boolean]("nonValue") must beNone
  }

  def acceptAConfigKey = prop { b: Boolean =>
    val cfg = ConfigFactory.parseString(s"myValue = $b")
    val key: ConfigKey[Boolean] = SimpleConfigKey("myValue")
    cfg(key) must beEqualTo(b)
  }
}

package net.ceedubs.ficus

import com.typesafe.config.ConfigFactory
import FicusConfig.{ booleanValueReader, optionValueReader, toFicusConfig }

class FicusConfigSpec extends Spec { def is =
  "A Ficus config should" ^
    "be implicitly converted from a Typesafe config" ! implicitlyConverted ^
    "read a value with a value reader" ! readAValue ^
    "get an existing value as a Some" ! getAsSome ^
    "get a missing value as a None" ! getAsNone ^
    "accept a CongigKey and return the appropriate type" ! acceptAConfigKey

  def implicitlyConverted = {
    val cfg = ConfigFactory.parseString("myValue = true")
    cfg.as[Boolean]("myValue") must beTrue
  }

  def readAValue = prop { b: Boolean =>
    val cfg = ConfigFactory.parseString(s"myValue = $b")
    cfg.as[Boolean]("myValue") must beEqualTo(b)
  }

  def getAsSome = prop { b: Boolean =>
    val cfg = ConfigFactory.parseString(s"myValue = $b")
    cfg.getAs[Boolean]("myValue") must beSome(b)
  }

  def getAsNone = {
    val cfg = ConfigFactory.parseString("myValue = true")
    cfg.getAs[Boolean]("nonValue") must beNone
  }

  def acceptAConfigKey = prop { b: Boolean =>
    val cfg = ConfigFactory.parseString(s"myValue = $b")
    val key: ConfigKey[Boolean] = SimpleConfigKey("myValue")
    cfg(key) must beEqualTo(b)
  }
}

Fix typos in FicusConfig spec

Fix typos in FicusConfig spec


addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0")

val sbtSoftwareMillVersion = "2.0.8"
addSbtPlugin(
  "com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion
)
addSbtPlugin(
  "com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion
)

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")

addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0")

val sbtSoftwareMillVersion = "2.0.8"
addSbtPlugin(
  "com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-common" % sbtSoftwareMillVersion
)
addSbtPlugin(
  "com.softwaremill.sbt-softwaremill" % "sbt-softwaremill-publish" % sbtSoftwareMillVersion
)

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")

Update sbt-scalajs, scalajs-library_2.13, ... to 1.8.0


addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")

addSbtPlugin("com.47deg" % "sbt-microsites" % "1.3.2")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")

addSbtPlugin("com.47deg" % "sbt-microsites" % "1.3.2")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.16")

Remove dependency graph plugin (install as global plugin if needed)


addSbtPlugin("io.gatling"         % "gatling-build-plugin"  % "4.3.1")
addSbtPlugin("com.github.sbt"     % "sbt-native-packager"   % "1.9.9")
addSbtPlugin("pl.project13.scala" % "sbt-jmh"               % "0.4.3")
addSbtPlugin("net.aichler"        % "sbt-jupiter-interface" % "0.9.1")
addSbtPlugin("com.typesafe.sbt"   % "sbt-site"              % "1.4.1")
addSbtPlugin("org.wartremover"    % "sbt-wartremover"       % "2.4.18")
addSbtPlugin("ch.epfl.scala"      % "sbt-scalafix"          % "0.9.34")
addSbtPlugin("com.hanhuy.sbt"     % "kotlin-plugin"         % "2.0.0")
addSbtPlugin("net.moznion.sbt"    % "sbt-spotless"          % "0.1.3")

addSbtPlugin("io.gatling"         % "gatling-build-plugin"  % "4.3.1")
addSbtPlugin("com.github.sbt"     % "sbt-native-packager"   % "1.9.9")
addSbtPlugin("pl.project13.scala" % "sbt-jmh"               % "0.4.3")
addSbtPlugin("net.aichler"        % "sbt-jupiter-interface" % "0.9.1")
addSbtPlugin("com.typesafe.sbt"   % "sbt-site"              % "1.4.1")
addSbtPlugin("org.wartremover"    % "sbt-wartremover"       % "2.4.19")
addSbtPlugin("ch.epfl.scala"      % "sbt-scalafix"          % "0.9.34")
addSbtPlugin("com.hanhuy.sbt"     % "kotlin-plugin"         % "2.0.0")
addSbtPlugin("net.moznion.sbt"    % "sbt-spotless"          % "0.1.3")

Update sbt-wartremover, wartremover to 2.4.19


addSbtPlugin("com.jsuereth"         % "sbt-pgp"               % "2.0.1")
addSbtPlugin("com.typesafe.sbt"     % "sbt-ghpages"           % "0.6.3")
addSbtPlugin("com.typesafe.sbt"     % "sbt-site"              % "1.4.0")
addSbtPlugin("org.scoverage"        % "sbt-scoverage"         % "1.6.0")
addSbtPlugin("com.typesafe.sbt"     % "sbt-git"               % "1.0.0")
addSbtPlugin("org.scala-js"         % "sbt-scalajs"           % "1.1.0")
addSbtPlugin("org.portable-scala"   % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.xerial.sbt"       % "sbt-sonatype"          % "3.9.3")
addSbtPlugin("ohnosequences"        % "sbt-github-release"    % "0.7.0")
addSbtPlugin("com.eed3si9n"         % "sbt-buildinfo"         % "0.9.0")

// https://github.com/ohnosequences/sbt-github-release/issues/28#issuecomment-426086656
libraryDependencies += "com.sun.activation" % "javax.activation" % "1.2.0"

addSbtPlugin("com.jsuereth"         % "sbt-pgp"               % "2.0.1")
addSbtPlugin("com.typesafe.sbt"     % "sbt-ghpages"           % "0.6.3")
addSbtPlugin("com.typesafe.sbt"     % "sbt-site"              % "1.4.0")
addSbtPlugin("org.scoverage"        % "sbt-scoverage"         % "1.6.0")
addSbtPlugin("com.typesafe.sbt"     % "sbt-git"               % "1.0.0")
addSbtPlugin("org.scala-js"         % "sbt-scalajs"           % "1.1.1")
addSbtPlugin("org.portable-scala"   % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.xerial.sbt"       % "sbt-sonatype"          % "3.9.3")
addSbtPlugin("ohnosequences"        % "sbt-github-release"    % "0.7.0")
addSbtPlugin("com.eed3si9n"         % "sbt-buildinfo"         % "0.9.0")

// https://github.com/ohnosequences/sbt-github-release/issues/28#issuecomment-426086656
libraryDependencies += "com.sun.activation" % "javax.activation" % "1.2.0"

Update sbt-scalajs, scalajs-compiler to 1.1.1


name := "pureconfig-cron4s"

crossScalaVersions ~= { _.filterNot(_.startsWith("2.13")) }

libraryDependencies ++= Seq(
  "com.github.alonsodomin.cron4s" %% "cron4s-core" % "0.5.0")

developers := List(
  Developer("bardurdam", "Bárður Viberg Dam", "bardurdam@gmail.com", url("https://github.com/bardurdam")))

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.cron4s.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")

name := "pureconfig-cron4s"

libraryDependencies += {
  val cron4sVersion = CrossVersion.partialVersion(scalaVersion.value) match {
    case Some((2, n)) if n < 12 => "0.5.0"
    case _                      => "0.6.0-M2"
  }

  "com.github.alonsodomin.cron4s" %% "cron4s-core" % cron4sVersion
}

developers := List(
  Developer("bardurdam", "Bárður Viberg Dam", "bardurdam@gmail.com", url("https://github.com/bardurdam")))

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.cron4s.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")

Support for Scala 2.13 in cron4s

Support for Scala 2.13 in cron4s

`cron4s` supports Scala 2.13 in the 0.6 version series, but at the same time drops support for Scala 2.11. This change makes this module available for all the cross Scala versions at the cost of choosing a different version of the dependency.

Other option would be dropping 2.11 support in this module.

ps: `cron4s` 0.6 will be source compatible with 0.5.


import com.google.appengine.api.datastore.dev.LocalDatastoreService
import com.google.appengine.tools.development.testing.{LocalDatastoreServiceTestConfig,LocalServiceTestHelper}
import java.io.File
import java.util.zip.{Checksum,CRC32}
import org.apache.lucene.index._
import org.apache.lucene.store._
import quotidian.search._

object DatastoreService {
	val helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig())
	val service = LocalServiceTestHelper.getLocalService(LocalDatastoreService.PACKAGE).asInstanceOf[LocalDatastoreService]
	def start = {
		service.start
	}
	def stop = {
		service.clearProfiles
		service.stop
	}
	def setup(filename:String) = {
		val fsd = FSDirectory.getDirectory("target/index")
		val fso = fsd.createOutput(filename)
		val fsi = fsd.openInput(filename)
		val dsd = new DatastoreDirectory
		val dso = dsd.createOutput(filename)
		val dsi = dsd.openInput(filename)
		(fsd,fso,fsi,dsd,dso,dsi)
	}
}

import com.google.appengine.api.datastore.dev.LocalDatastoreService
import com.google.appengine.api.labs.taskqueue.dev.LocalTaskQueue
import com.google.appengine.tools.development.testing.{LocalDatastoreServiceTestConfig,LocalServiceTestHelper}
import java.io.File
import java.util.zip.{Checksum,CRC32}
import org.apache.lucene.index._
import org.apache.lucene.store._
import quotidian.search._

object DatastoreService {
	val helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig())
	val service = LocalServiceTestHelper.getLocalService(LocalDatastoreService.PACKAGE).asInstanceOf[LocalDatastoreService]
	val taskQueue = LocalServiceTestHelper.getLocalService(LocalTaskQueue.PACKAGE).asInstanceOf[LocalTaskQueue]
	def start = {
		service.start
	}
	def stop = {
		service.clearProfiles
		service.stop
	}
	def setup(filename:String) = {
		val fsd = FSDirectory.getDirectory("target/index")
		val fso = fsd.createOutput(filename)
		val fsi = fsd.openInput(filename)
		val dsd = new DatastoreDirectory
		val dso = dsd.createOutput(filename)
		val dsi = dsd.openInput(filename)
		(fsd,fso,fsi,dsd,dso,dsi)
	}
}

Add task queue reference to parent specification class


/*
 * Telefónica Digital - Product Development and Innovation
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Copyright (c) Telefónica Investigación y Desarrollo S.A.U.
 * All rights reserved.
 */

package es.tid.cosmos.api.controllers.common

import play.api.data.validation.ValidationError
import play.api.libs.json._
import play.api.mvc.{Action, Controller, Request, Result}

/**
 * JSON consuming controller.
 */
trait JsonController extends Controller {
  def JsonBodyAction[Payload: Reads](f: (Request[JsValue], Payload) => Result): Action[JsValue] =
    Action(parse.tolerantJson) { request =>
      Json.fromJson[Payload](request.body).fold(
        invalid = formatErrors,
        valid = payload => f(request, payload))
    }

  private def formatErrors(errors: Seq[(JsPath, Seq[ValidationError])]) = {
    val formattedErrors = errors.map {
      case (path, errors) => (path.toString(), errors.map(_.message))
    }
    BadRequest(Json.toJson(Map(formattedErrors: _*)))
  }
}

/*
 * Telefónica Digital - Product Development and Innovation
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Copyright (c) Telefónica Investigación y Desarrollo S.A.U.
 * All rights reserved.
 */

package es.tid.cosmos.api.controllers.common

import play.api.data.validation.ValidationError
import play.api.libs.json._
import play.api.mvc.{Action, Controller, Request, Result}

/**
 * JSON consuming controller.
 */
trait JsonController extends Controller {
  def JsonBodyAction[Payload: Reads](f: (Request[JsValue], Payload) => Result): Action[JsValue] =
    Action(parse.tolerantJson) { request =>
      Json.fromJson[Payload](request.body).fold(
        invalid = formatErrors,
        valid = payload => f(request, payload))
    }

  private def formatErrors(errorsByPath: Seq[(JsPath, Seq[ValidationError])]) = {
    val formattedErrors = errorsByPath.map {
      case (path, errors) => (path.toString(), errors.map(_.message))
    }
    BadRequest(Json.toJson(Map(formattedErrors: _*)))
  }
}

Rename variable to avoid name shadowing

Rename variable to avoid name shadowing


package hmda.model.edits

import hmda.model.ResourceUtils
import com.github.tototoshi.csv.CSVParser.parse

object EditMetaDataLookup extends ResourceUtils {
  val values: Seq[EditMetaData] = {
    val lines = resourceLines("/edit-metadata.txt")

    lines.drop(1).map { line =>
      val values = parse(line, '\\', ',', '"').getOrElse(List())
      val category = values(0)
      val editType = values(1)
      val editNumber = values(2)
      val editDescription = values(3)
      val userFriendlyEditDescription = values(4)
      val fieldNames: Seq[String] = values(5).split(";").map(_.trim)

      EditMetaData(
        editNumber,
        editDescription,
        userFriendlyEditDescription,
        fieldNames
      )

    }.toSeq
  }

  def forEdit(editName: String): EditMetaData = {
    values.find(e => e.editNumber == editName)
      .getOrElse(EditMetaData(editName, "description not found", "description not found", Seq()))
  }
}

case class EditMetaData(
  editNumber: String,
  editDescription: String,
  userFriendlyEditDescription: String,
  fieldNames: Seq[String]
)

package hmda.model.edits

import hmda.model.ResourceUtils
import com.github.tototoshi.csv.CSVParser.parse

object EditMetaDataLookup extends ResourceUtils {
  val values: Seq[EditMetaData] = {
    val lines = resourceLines("/edit-metadata.txt")

    lines.drop(1).map { line =>
      val values = parse(line, '\\', ',', '"').getOrElse(List())
      val category = values(0)
      val editType = values(1)
      val editNumber = values(2)
      val editDescription = values(3)
      val userFriendlyEditDescription = values(4)
      val fieldNames: Seq[String] = values(5).split(";").map(_.trim).filter(_.nonEmpty)

      EditMetaData(
        editNumber,
        editDescription,
        userFriendlyEditDescription,
        fieldNames
      )

    }.toSeq
  }

  def forEdit(editName: String): EditMetaData = {
    values.find(e => e.editNumber == editName)
      .getOrElse(EditMetaData(editName, "description not found", "description not found", Seq()))
  }
}

case class EditMetaData(
  editNumber: String,
  editDescription: String,
  userFriendlyEditDescription: String,
  fieldNames: Seq[String]
)

Remove empty entries - in case of extra semicolons in fields list


package com.github.mrpowers.spark.daria.sql

import org.apache.spark.sql.{DataFrame, SparkSession}
import org.apache.spark.sql.Row
import org.apache.spark.sql.types.{DataType, StructField, StructType}

object SparkSessionExt {

  implicit class SparkSessionMethods(spark: SparkSession) {

    // double definition error due to Type Erasure: http://stackoverflow.com/a/4982668/1125159

    private def asRows[U](values: List[U]): List[Row] = {
      values map {
        case x: Row => x.asInstanceOf[Row]
        case y: Product => Row(y.productIterator.toList: _*)
        case a => Row(a)
      }
    }

    def createDF[U](
      rowData: List[U],
      fields: List[(String, DataType, Boolean)]
    ): DataFrame = {
      val structFields = fields.map(field => {
        StructField(field._1, field._2, field._3)
      })
      spark.createDF(asRows(rowData), structFields)
    }

    // weird method signature per this Stackoverflow thread: http://stackoverflow.com/a/4982668/1125159

    def createDF[U](
      rowData: List[U],
      schema: List[StructField]
    )(implicit i1: DummyImplicit): DataFrame = {
      spark.createDataFrame(
        spark.sparkContext.parallelize(asRows(rowData)),
        StructType(schema)
      )
    }
  }
}

package com.github.mrpowers.spark.daria.sql

import org.apache.spark.sql.{DataFrame, SparkSession}
import org.apache.spark.sql.Row
import org.apache.spark.sql.types.{DataType, StructField, StructType}

object SparkSessionExt {

  implicit class SparkSessionMethods(spark: SparkSession) {

    private def asRows[U](values: List[U]): List[Row] = {
      values map {
        case x: Row => x.asInstanceOf[Row]
        case y: Product => Row(y.productIterator.toList: _*)
        case a => Row(a)
      }
    }

    private def asSchema[U](fields: List[U]): List[StructField] = {
      fields map {
        case x: StructField => x.asInstanceOf[StructField]
        case (name: String, dataType: DataType, nullable: Boolean) =>
          StructField(name, dataType, nullable)
      }
    }

    def createDF[U, T](rowData: List[U], fields: List[T]): DataFrame = {
      spark.createDataFrame(
        spark.sparkContext.parallelize(asRows(rowData)),
        StructType(asSchema(fields))
      )
    }
  }

}

Refactor to use Generics for StructField


object Solution {

  def numberOfDivisors(n: Int): Int = n match {
    case x if x <= 0 => 0
    case 1 => 1
    case x =>
      var i = 2
      while (i * i <= x && x % i != 0) {
        i += 1
      }
      if (i * i <= x) {
        var j = 1
        var num = n
        while (num % i == 0) {
          num /= i
          j += 1
        }
        j * numberOfDivisors(num)
      }
      else 2
  }

  def main(args: Array[String]) {
    for (_ <- 1 to readInt) {
      val n = readInt
      if (n % 2 == 0) println(numberOfDivisors(n / 2))
      else println(0)
    }
  }
}

object Solution {

  def numberOfDivisors(n: Int): Int = {
    var ans = 1
    var p = 2
    var nn = n
    while (p <= nn) {
      if (p * p > nn) p = nn // nn is a prime, we don't need to check further.
      var e = 1
      while (nn % p == 0) {
        nn /= p
        e += 1
      }
      ans *= e
      p += 1
    }
    ans
  }

  def main(args: Array[String]) {
    for (_ <- 1 to readInt) {
      val n = readInt
      if (n % 2 == 0) println(numberOfDivisors(n / 2))
      else println(0)
    }
  }
}

Update solution to Sherlock and Divisors.


// Run sbt eclipse to create Eclipse project file
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")

// Run sbt gen-idea to create IntelliJ project file
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

// Run sbt checkVersions to check updated versions of dependencies
addSbtPlugin("com.sksamuel.sbt-versions" % "sbt-versions" % "0.2.0")

// Run sbt mima-report-binary-issues to check for binary compatibility
// http://www.typesafe.com/community/core-tools/migration-manager
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.6")

// Run sbt eclipse to create Eclipse project file
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.3.0")

// Run sbt gen-idea to create IntelliJ project file
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

// Run sbt checkVersions to check updated versions of dependencies
addSbtPlugin("com.sksamuel.sbt-versions" % "sbt-versions" % "0.2.0")

// Run sbt mima-report-binary-issues to check for binary compatibility
// http://www.typesafe.com/community/core-tools/migration-manager
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.6")

Use sbteclipse-plugin 2.3.0 as in xitrum-new and xitrum-demos


resolvers += Resolver.url(
  "bintray-sbt-plugin-releases",
  url("http://dl.bintray.com/content/sbt/sbt-plugin-releases"))(
    Resolver.ivyStylePatterns)
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.1.2")

addSbtPlugin("org.brianmckenna" % "sbt-wartremover" % "0.14")

resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")

addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "0.5.2")

resolvers += Resolver.url(
  "bintray-sbt-plugin-releases",
  url("http://dl.bintray.com/content/sbt/sbt-plugin-releases"))(
    Resolver.ivyStylePatterns)
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.1.2")

addSbtPlugin("org.brianmckenna" % "sbt-wartremover" % "0.14")

resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")

addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "0.5.2")

Update dependency com.typesafe.sbt:sbt-git to v1


package scorex.transaction

import java.io._

import org.scalacheck.Gen
import org.scalatest.prop.{GeneratorDrivenPropertyChecks, PropertyChecks}
import org.scalatest.{Matchers, PropSpec}
import scorex.transaction.state.database.state._

class RowSpecification extends PropSpec
  with PropertyChecks
  with GeneratorDrivenPropertyChecks
  with Matchers
  with TransactionGen {

  val FileName = "object.data"

  property("Row serialize and deserialize") {
    forAll(paymentGenerator, Gen.posNum[Long], Gen.posNum[Long], Gen.posNum[Int]) { (payment: PaymentTransaction,
                                                                                balance: Long,
                                                                                fee: Long,
                                                                                lastRowHeight: Int) =>

      val txs = List(FeesStateChange(fee), payment)
      LagonakiTransaction.parseBytes(payment.bytes).get shouldBe payment
      val row = Row(AccState(balance), txs, lastRowHeight)

      val objectOutputStream = new ObjectOutputStream(new FileOutputStream(FileName))
      objectOutputStream.writeObject(row)
      objectOutputStream.close()

      val objectInputStream = new ObjectInputStream(new FileInputStream(FileName))
      val des = objectInputStream.readObject().asInstanceOf[Row]
      des shouldBe row
    }
  }

}

package scorex.transaction

import java.io._

import org.scalacheck.Gen
import org.scalatest.prop.{GeneratorDrivenPropertyChecks, PropertyChecks}
import org.scalatest.{BeforeAndAfterAll, Matchers, PropSpec}
import scorex.transaction.state.database.state._

class RowSpecification extends PropSpec
  with PropertyChecks
  with GeneratorDrivenPropertyChecks
  with Matchers
  with TransactionGen
  with BeforeAndAfterAll {

  val FileName = "object.data"

  override def afterAll(): Unit = {
    val testDataFile = new File(FileName)
    if (testDataFile.exists) testDataFile.delete
  }

  property("Row serialize and deserialize") {
    forAll(paymentGenerator, Gen.posNum[Long], Gen.posNum[Long], Gen.posNum[Int]) { (payment: PaymentTransaction,
                                                                                balance: Long,
                                                                                fee: Long,
                                                                                lastRowHeight: Int) =>

      val txs = List(FeesStateChange(fee), payment)
      LagonakiTransaction.parseBytes(payment.bytes).get shouldBe payment
      val row = Row(AccState(balance), txs, lastRowHeight)

      val objectOutputStream = new ObjectOutputStream(new FileOutputStream(FileName))
      objectOutputStream.writeObject(row)
      objectOutputStream.close()

      val objectInputStream = new ObjectInputStream(new FileInputStream(FileName))
      val des = objectInputStream.readObject().asInstanceOf[Row]
      des shouldBe row
    }
  }

}

Test data file removal after test was implemented.


import app._
import org.scalatra._
import javax.servlet._

class ScalatraBootstrap extends LifeCycle {
  override def init(context: ServletContext) {
    context.mount(new IndexController, "/")
    context.mount(new SignInController, "/*")
    context.mount(new UserManagementController, "/*")
    context.mount(new SystemSettingsController, "/*")
    context.mount(new CreateRepositoryController, "/*")
    context.mount(new AccountController, "/*")
    context.mount(new RepositoryViewerController, "/*")
    context.mount(new WikiController, "/*")
    context.mount(new LabelsController, "/*")
    context.mount(new MilestonesController, "/*")
    context.mount(new IssuesController, "/*")
    context.mount(new SettingsController, "/*")

    context.addListener(new ServletContextListener(){
      def contextInitialized(e: ServletContextEvent): Unit = {
        val dir = new java.io.File(_root_.util.Directory.GitBucketHome)
        if(!dir.exists){
          dir.mkdirs()
        }
      }

      def contextDestroyed(e: ServletContextEvent): Unit = {}
    })
  }
}

import app._
import org.scalatra._
import javax.servlet._

class ScalatraBootstrap extends LifeCycle {
  override def init(context: ServletContext) {
    context.mount(new IndexController, "/")
    context.mount(new SignInController, "/*")
    context.mount(new UserManagementController, "/*")
    context.mount(new SystemSettingsController, "/*")
    context.mount(new CreateRepositoryController, "/*")
    context.mount(new AccountController, "/*")
    context.mount(new RepositoryViewerController, "/*")
    context.mount(new WikiController, "/*")
    context.mount(new LabelsController, "/*")
    context.mount(new MilestonesController, "/*")
    context.mount(new IssuesController, "/*")
    context.mount(new SettingsController, "/*")

    val dir = new java.io.File(_root_.util.Directory.GitBucketHome)
    if(!dir.exists){
      dir.mkdirs()
    }
  }
}

Fix bootstrap problem on Tomcat.

Fix bootstrap problem on Tomcat.


val scalaJSVersion = sys.env.getOrElse("SCALAJS_VERSION", "1.1.1")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")

addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")

addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")

val scalaJSVersion = sys.env.getOrElse("SCALAJS_VERSION", "1.2.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")

addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")

addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")

Update sbt-scalajs, scalajs-compiler to 1.2.0


addSbtPlugin("com.jsuereth"         % "sbt-pgp"               % "2.0.1")
addSbtPlugin("com.typesafe.sbt"     % "sbt-ghpages"           % "0.6.3")
addSbtPlugin("com.typesafe.sbt"     % "sbt-site"              % "1.4.0")
addSbtPlugin("org.scoverage"        % "sbt-scoverage"         % "1.6.0")
addSbtPlugin("com.typesafe.sbt"     % "sbt-git"               % "1.0.0")
addSbtPlugin("org.scala-js"         % "sbt-scalajs"           % "1.2.0")
addSbtPlugin("org.portable-scala"   % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.xerial.sbt"       % "sbt-sonatype"          % "3.9.4")
addSbtPlugin("ohnosequences"        % "sbt-github-release"    % "0.7.0")
addSbtPlugin("com.eed3si9n"         % "sbt-buildinfo"         % "0.10.0")

// https://github.com/ohnosequences/sbt-github-release/issues/28#issuecomment-426086656
libraryDependencies += "com.sun.activation" % "javax.activation" % "1.2.0"

addSbtPlugin("com.jsuereth"         % "sbt-pgp"               % "2.0.1")
addSbtPlugin("com.typesafe.sbt"     % "sbt-ghpages"           % "0.6.3")
addSbtPlugin("com.typesafe.sbt"     % "sbt-site"              % "1.4.0")
addSbtPlugin("org.scoverage"        % "sbt-scoverage"         % "1.6.0")
addSbtPlugin("com.typesafe.sbt"     % "sbt-git"               % "1.0.0")
addSbtPlugin("org.scala-js"         % "sbt-scalajs"           % "1.3.0")
addSbtPlugin("org.portable-scala"   % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.xerial.sbt"       % "sbt-sonatype"          % "3.9.4")
addSbtPlugin("ohnosequences"        % "sbt-github-release"    % "0.7.0")
addSbtPlugin("com.eed3si9n"         % "sbt-buildinfo"         % "0.10.0")

// https://github.com/ohnosequences/sbt-github-release/issues/28#issuecomment-426086656
libraryDependencies += "com.sun.activation" % "javax.activation" % "1.2.0"

Update sbt-scalajs, scalajs-compiler to 1.3.0


// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.0-RC2")

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.0-M3")

addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.2")

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.0-M3")

addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.2")

Update Play version to 2.3.0.

Update Play version to 2.3.0.


addSbtPlugin("com.typesafe.play" % "sbt-plugin"   % "2.8.6")
addSbtPlugin("org.scalameta"     % "sbt-scalafmt" % "2.4.2")

addSbtPlugin("com.typesafe.play" % "sbt-plugin"   % "2.8.7")
addSbtPlugin("org.scalameta"     % "sbt-scalafmt" % "2.4.2")

Update play-akka-http-server, play-docs, ... to 2.8.7


addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.6")
addSbtPlugin("org.scalameta"     % "sbt-scalafmt" % "2.4.2")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")
addSbtPlugin("org.scalameta"     % "sbt-scalafmt" % "2.4.2")

Update play-ahc-ws, play-akka-http-server, ... to 2.8.7


addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")

addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.9")

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")

addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")

addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")

addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.9")

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")

addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")

Update sbt-scalajs, scalajs-compiler, ... to 1.10.0


resolvers += "Flyway" at "http://flywaydb.org/repo"

addSbtPlugin("org.flywaydb" % "flyway-sbt" % "3.2.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.3")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.0.4")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.0.0")

resolvers += "Flyway" at "https://flywaydb.org/repo"

addSbtPlugin("org.flywaydb" % "flyway-sbt" % "3.2.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.3")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.0.4")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.0.0")

Update Flyway repo URL to fix build

Update Flyway repo URL to fix build


// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1-SNAPSHOT")

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.0")

Set the play sbt-plugin version back.

Set the play sbt-plugin version back.


// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.6")

// Dependency graph plugin
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.3")

addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.3.0")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.3.2")

libraryDependencies += "org.javassist" % "javassist" % "3.18.2-GA"

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.6")

// Dependency graph plugin
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.0.3")

addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.4.0")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.3.2")

libraryDependencies += "org.javassist" % "javassist" % "3.18.2-GA"

Fix the failure of 'activator findbugs'

Fix the failure of 'activator findbugs'

It failed because findbugs 2 doesn't support Java 8. Upgrade
findbugs4sbt to 1.4.0 which uses findbugs 3.0.0. which supports Java 8.


lazy val root = (project in file(".")).enablePlugins(UniversalPlugin)

net.virtualvoid.sbt.graph.Plugin.graphSettings

name := "oxyjen"

version := "0.1"

scalaVersion := "2.11.4"

libraryDependencies ++= Seq(
  "ch.qos.logback" % "logback-classic" % "1.0.13",
  "commons-io" % "commons-io" % "2.4",
  "org.apache.ivy" % "ivy" % "2.3.0",
  "net.lingala.zip4j" % "zip4j" % "1.3.2",
  "net.databinder.dispatch" %% "dispatch-core" % "0.11.2",
  "org.json4s" %% "json4s-native" % "3.2.11",
  "org.scalatest" %% "scalatest" % "2.2.1" % "test")

mappings in Universal <+= (packageBin in Compile) map { jar =>
  jar -> "oxyjen.jar"
}

mappings in Universal <++= (fullClasspath in Compile) map { jars =>
  for (jar <- jars) yield
    jar.data -> ("lib/" + jar.data.getName)
}

lazy val root = (project in file(".")).enablePlugins(UniversalPlugin)

net.virtualvoid.sbt.graph.Plugin.graphSettings

name := "oxyjen"

version := "0.1"

scalaVersion := "2.11.4"

libraryDependencies ++= Seq(
  "ch.qos.logback" % "logback-classic" % "1.0.13",
  "commons-io" % "commons-io" % "2.4",
  "org.apache.ivy" % "ivy" % "2.3.0",
  "net.lingala.zip4j" % "zip4j" % "1.3.2",
  "net.databinder.dispatch" %% "dispatch-core" % "0.11.2",
  "org.json4s" %% "json4s-native" % "3.2.11" exclude("org.scala-lang", "scala-compiler"),
  "org.scalatest" %% "scalatest" % "2.2.1" % "test")

mappings in Universal <+= (packageBin in Compile) map { jar =>
  jar -> "oxyjen.jar"
}

mappings in Universal <++= (fullClasspath in Compile) map { jars =>
  for (jar <- jars) yield
    jar.data -> ("lib/" + jar.data.getName)
}

Exclude scala-compiler from scalap (json4s's transitive dependency) to shrink the resulting binary.


name := "lib-apidoc-json-validation"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.4"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.6",
      "org.scalatest" %% "scalatest" % "2.2.6" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

name := "lib-apidoc-json-validation"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.5"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.6",
      "org.scalatest" %% "scalatest" % "2.2.6" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

autocommit: Update configuration to record version 0.0.5


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.12"

crossScalaVersions := Seq("2.11.12")

version := "0.4.20"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      filters,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
      "org.scalatestplus" %% "play" % "1.4.0" % "test"
    ),
    resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
    resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
    resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/",
    credentials += Credentials(
      "Artifactory Realm",
      "flow.artifactoryonline.com",
      System.getenv("ARTIFACTORY_USERNAME"),
      System.getenv("ARTIFACTORY_PASSWORD")
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.12"

crossScalaVersions := Seq("2.11.12")

version := "0.4.22"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      filters,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
      "org.scalatestplus" %% "play" % "1.4.0" % "test"
    ),
    resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
    resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
    resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/",
    credentials += Credentials(
      "Artifactory Realm",
      "flow.artifactoryonline.com",
      System.getenv("ARTIFACTORY_USERNAME"),
      System.getenv("ARTIFACTORY_PASSWORD")
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

autocommit: Update configuration to record version 0.4.22


name := "lib-reference-scala"

organization := "io.flow"

scalaVersion := "2.13.6"

lazy val allScalacOptions = Seq(
  "-feature",
  "-Xfatal-warnings",
  "-unchecked",
  "-Xcheckinit",
  "-Xlint:adapted-args",
  "-Ypatmat-exhaust-depth", "100", // Fixes: Exhaustivity analysis reached max recursion depth, not all missing cases are reported.
  "-Wconf:src=generated/.*:silent",
  "-Wconf:src=target/.*:silent", // silence the unused imports errors generated by the Play Routes
)

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.2.10" % Test,
    ),
    credentials += Credentials(
      "Artifactory Realm",
      "flow.jfrog.io",
      System.getenv("ARTIFACTORY_USERNAME"),
      System.getenv("ARTIFACTORY_PASSWORD")
    )
  )

publishTo := {
  val host = "https://flow.jfrog.io/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

scalacOptions ++= allScalacOptions

version := "0.2.90"

name := "lib-reference-scala"

organization := "io.flow"

scalaVersion := "2.13.6"

lazy val allScalacOptions = Seq(
  "-feature",
  "-Xfatal-warnings",
  "-unchecked",
  "-Xcheckinit",
  "-Xlint:adapted-args",
  "-Ypatmat-exhaust-depth", "100", // Fixes: Exhaustivity analysis reached max recursion depth, not all missing cases are reported.
  "-Wconf:src=generated/.*:silent",
  "-Wconf:src=target/.*:silent", // silence the unused imports errors generated by the Play Routes
)

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.2.10" % Test,
    ),
    credentials += Credentials(
      "Artifactory Realm",
      "flow.jfrog.io",
      System.getenv("ARTIFACTORY_USERNAME"),
      System.getenv("ARTIFACTORY_PASSWORD")
    )
  )

publishTo := {
  val host = "https://flow.jfrog.io/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

scalacOptions ++= allScalacOptions

version := "0.2.91"

autocommit: Update configuration to record version 0.2.91


import sbt.Keys.version
import sbt._

object Common {
  val versionString = "1.3"
  val scalaVersionString = "2.10.3"
  val organisationString = "dvla"
  val organisationNameString = "Driver & Vehicle Licensing Agency"
  val nexus = "http://rep002-01.skyscape.preview-dvla.co.uk:8081/nexus/content/repositories"

  val scalaOptionsSeq = Seq(
    "-deprecation",
    "-unchecked",
    "-feature",
    "-Xlint",
    "-language:reflectiveCalls",
    "-Xmax-classfile-name", "128"
  )

  val projectResolvers = Seq(
    "typesafe repo" at "http://repo.typesafe.com/typesafe/releases",
    "spray repo" at "http://repo.spray.io/",
    "local nexus snapshots" at s"$nexus/snapshots",
    "local nexus releases" at s"$nexus/releases"
  )

  val publishResolver: sbt.Def.Initialize[Option[sbt.Resolver]] = version { v: String =>
    if (v.trim.endsWith("SNAPSHOT"))
      Some("snapshots" at s"$nexus/snapshots")
    else
      Some("releases" at s"$nexus/releases")
  }

  val sbtCredentials = Credentials(Path.userHome / ".sbt/.credentials")
}

import sbt.Keys.version
import sbt._

object Common {
  val versionString = "1.0-SNAPSHOT"
  val scalaVersionString = "2.10.3"
  val organisationString = "dvla"
  val organisationNameString = "Driver & Vehicle Licensing Agency"
  val nexus = "http://rep002-01.skyscape.preview-dvla.co.uk:8081/nexus/content/repositories"

  val scalaOptionsSeq = Seq(
    "-deprecation",
    "-unchecked",
    "-feature",
    "-Xlint",
    "-language:reflectiveCalls",
    "-Xmax-classfile-name", "128"
  )

  val projectResolvers = Seq(
    "typesafe repo" at "http://repo.typesafe.com/typesafe/releases",
    "spray repo" at "http://repo.spray.io/",
    "local nexus snapshots" at s"$nexus/snapshots",
    "local nexus releases" at s"$nexus/releases"
  )

  val publishResolver: sbt.Def.Initialize[Option[sbt.Resolver]] = version { v: String =>
    if (v.trim.endsWith("SNAPSHOT"))
      Some("snapshots" at s"$nexus/snapshots")
    else
      Some("releases" at s"$nexus/releases")
  }

  val sbtCredentials = Credentials(Path.userHome / ".sbt/.credentials")
}

Put the version back to 1.0-SNAPSHOT

Put the version back to 1.0-SNAPSHOT


import sbt._
import sbt.Keys._
import android.Keys._
import android.Plugin._

object Build extends android.AutoBuild
{
	lazy val main = Project( "toolbelt", file( "." ) )
		.settings( androidBuildAar: _* )
		.settings(
			libraryDependencies ++= Seq(
				"com.android.support" % "appcompat-v7" % "21.0.0",
				"com.github.japgolly.android" % "svg-android" % "2.0.6",
				"com.jpardogo.materialtabstrip" % "library" % "1.0.5",
				"org.scala-lang" % "scala-reflect" % scalaVersion.value
			),
			name := "Toolbelt",
			organization := "com.taig.android",
			publishArtifact in ( Compile, packageDoc ) := false,
			scalaVersion := "2.11.4",
			scalacOptions ++= Seq(
				"-deprecation",
				"-feature",
				"-language:dynamics",
				"-language:existentials",
				"-language:implicitConversions",
				"-language:reflectiveCalls"
			),
			// @see https://github.com/pfn/android-sdk-plugin/issues/88
			sourceGenerators in Compile <<= ( sourceGenerators in Compile ) ( generators => Seq( generators.last ) ),
			version := "0.3.18-BETA",
			minSdkVersion in Android := "10",
			platformTarget in Android := "android-21",
			targetSdkVersion in Android := "21"
		)
}

import sbt._
import sbt.Keys._
import android.Keys._
import android.Plugin._

object Build extends android.AutoBuild
{
	lazy val main = Project( "toolbelt", file( "." ) )
		.settings( androidBuildAar: _* )
		.settings(
			libraryDependencies ++= Seq(
				"com.android.support" % "appcompat-v7" % "21.0.0",
				"com.github.japgolly.android" % "svg-android" % "2.0.6",
				"com.jpardogo.materialtabstrip" % "library" % "1.0.5",
				"org.scala-lang" % "scala-reflect" % scalaVersion.value
			),
			name := "Toolbelt",
			organization := "com.taig.android",
			publishArtifact in ( Compile, packageDoc ) := false,
			scalaVersion := "2.11.4",
			scalacOptions ++= Seq(
				"-deprecation",
				"-feature",
				"-language:dynamics",
				"-language:existentials",
				"-language:implicitConversions",
				"-language:reflectiveCalls"
			),
			// @see https://github.com/pfn/android-sdk-plugin/issues/88
			sourceGenerators in Compile <<= ( sourceGenerators in Compile ) ( generators => Seq( generators.last ) ),
			version := "0.3.19-BETA",
			minSdkVersion in Android := "10",
			platformTarget in Android := "android-21",
			targetSdkVersion in Android := "21"
		)
}

Set project version to 0.3.19-BETA

Set project version to 0.3.19-BETA


addSbtPlugin("com.47deg" % "sbt-microsites" % "0.7.23")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.9")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.2")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.6.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.8")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")

addSbtPlugin("com.47deg" % "sbt-microsites" % "0.7.23")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.9")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.2")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.6.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.9")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")

Update nscplugin, sbt-scala-native to 0.3.9


addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.7.0")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("org.http4s" %% "sbt-http4s-org" % "0.14.5")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.7.0")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("org.http4s" %% "sbt-http4s-org" % "0.14.6")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

Update sbt-http4s-org to 0.14.6 in series/0.23


name := "lib-reference-scala"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.3"

crossScalaVersions := Seq("2.12.3", "2.11.11", "2.10.6")

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.0.4" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

version := "0.1.32"

name := "lib-reference-scala"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.3"

crossScalaVersions := Seq("2.12.3", "2.11.11", "2.10.6")

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % "3.0.4" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

version := "0.1.33"

autocommit: Update configuration to record version 0.1.33


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.7"

crossScalaVersions := Seq("2.11.7")

version := "0.0.49"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      "org.scalatest" %% "scalatest" % "2.2.6" % "test",
      "org.scalatestplus" %% "play" % "1.4.0" % "test"
    )
)

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.7"

crossScalaVersions := Seq("2.11.7")

version := "0.0.50"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      "org.scalatest" %% "scalatest" % "2.2.6" % "test",
      "org.scalatestplus" %% "play" % "1.4.0" % "test"
    )
)

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

autocommit: Update configuration to record version 0.0.50


name := "rorschach"

version := "1.0"

scalaVersion := "2.11.5"

mainClass := Some("com.getbootstrap.rorschach.server.Boot")

resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)

libraryDependencies += "org.eclipse.mylyn.github" % "org.eclipse.egit.github.core" % "2.1.5"

libraryDependencies ++= {
  val akkaV = "2.3.9"
  val sprayV = "1.3.2"
  Seq(
    "io.spray"            %%  "spray-can"     % sprayV,
    "io.spray"            %%  "spray-routing" % sprayV,
    "io.spray"            %%  "spray-testkit" % sprayV   % "test",
    "com.typesafe.akka"   %%  "akka-actor"    % akkaV,
    "com.typesafe.akka"   %%  "akka-testkit"  % akkaV    % "test",
    "org.specs2"          %%  "specs2"        % "2.3.12" % "test"
  )
}

scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "–Xlint", "-encoding", "utf8")

scalacOptions in Test ++= Seq("-Yrangepos")

// parallelExecution in Test := false

Revolver.settings

name := "rorschach"

version := "1.0"

scalaVersion := "2.11.5"

mainClass := Some("com.getbootstrap.rorschach.server.Boot")

resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)

resolvers += "Eclipse Foundation Releases" at "https://repo.eclipse.org/content/repositories/releases/"

resolvers += "Eclipse Foundation Snapshots" at "https://repo.eclipse.org/content/repositories/snapshots/"

libraryDependencies += "org.eclipse.mylyn.github" % "org.eclipse.egit.github.core" % "2.1.5"

libraryDependencies ++= {
  val akkaV = "2.3.9"
  val sprayV = "1.3.2"
  Seq(
    "io.spray"            %%  "spray-can"     % sprayV,
    "io.spray"            %%  "spray-routing" % sprayV,
    "io.spray"            %%  "spray-testkit" % sprayV   % "test",
    "com.typesafe.akka"   %%  "akka-actor"    % akkaV,
    "com.typesafe.akka"   %%  "akka-testkit"  % akkaV    % "test",
    "org.specs2"          %%  "specs2"        % "2.3.12" % "test"
  )
}

scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "–Xlint", "-encoding", "utf8")

scalacOptions in Test ++= Seq("-Yrangepos")

// parallelExecution in Test := false

Revolver.settings

Add Eclipse Foundation Maven repos to resolvers


name := "proxy"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .enablePlugins(NewRelic)
  .settings(commonSettings: _*)
  .settings(
    libraryDependencies ++= Seq(
      filters,
      ws,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
      "org.yaml" % "snakeyaml" % "1.17",
      "org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0" % "test"
    )
  )

val credsToUse = Option(System.getenv("ARTIFACTORY_USERNAME")) match {
  case None => Credentials(Path.userHome / ".ivy2" / ".artifactory")
  case _ => Credentials("Artifactory Realm","flow.artifactoryonline.com",System.getenv("ARTIFACTORY_USERNAME"),System.getenv("ARTIFACTORY_PASSWORD"))
}

lazy val commonSettings: Seq[Setting[_]] = Seq(
  name <<= name("proxy-" + _),
  scalacOptions += "-feature",
  sources in (Compile,doc) := Seq.empty,
  publishArtifact in (Compile, packageDoc) := false,
  credentials += credsToUse,
  resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
  resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/"
)

version := "0.0.21"

name := "proxy"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .enablePlugins(NewRelic)
  .settings(commonSettings: _*)
  .settings(
    libraryDependencies ++= Seq(
      filters,
      ws,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
      "org.yaml" % "snakeyaml" % "1.17",
      "org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0" % "test"
    )
  )

val credsToUse = Option(System.getenv("ARTIFACTORY_USERNAME")) match {
  case None => Credentials(Path.userHome / ".ivy2" / ".artifactory")
  case _ => Credentials("Artifactory Realm","flow.artifactoryonline.com",System.getenv("ARTIFACTORY_USERNAME"),System.getenv("ARTIFACTORY_PASSWORD"))
}

lazy val commonSettings: Seq[Setting[_]] = Seq(
  name <<= name("proxy-" + _),
  scalacOptions += "-feature",
  sources in (Compile,doc) := Seq.empty,
  publishArtifact in (Compile, packageDoc) := false,
  credentials += credsToUse,
  resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
  resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/"
)

version := "0.0.22"

autocommit: Update configuration to record version 0.0.22


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.1.11"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.10",
      "com.ning" % "async-http-client" % "1.9.40",
      "org.scalatest" %% "scalatest" % "3.0.1" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.1.13"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.10",
      "com.ning" % "async-http-client" % "1.9.40",
      "org.scalatest" %% "scalatest" % "3.0.1" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

autocommit: Update configuration to record version 0.1.13


name := "apibuilder-validation"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.4"

crossScalaVersions := Seq("2.12.4", "2.11.12")

version := "0.1.17"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.6.8",
      "org.scalatest" %% "scalatest" % "3.0.4" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

name := "apibuilder-validation"

organization := "io.flow"

scalaVersion in ThisBuild := "2.12.4"

crossScalaVersions := Seq("2.12.4", "2.11.12")

version := "0.1.18"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.6.8",
      "org.scalatest" %% "scalatest" % "3.0.4" % Test
    )
  )

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

autocommit: Update configuration to record version 0.1.18


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

crossScalaVersions := Seq("2.11.8")

version := "0.2.19"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      filters,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
      "org.scalatestplus" %% "play" % "1.4.0" % "test"
    ),
    resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
    resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
    resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/",
    credentials += Credentials(
      "Artifactory Realm",
      "flow.artifactoryonline.com",
      System.getenv("ARTIFACTORY_USERNAME"),
      System.getenv("ARTIFACTORY_PASSWORD")
    )
)

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

crossScalaVersions := Seq("2.11.8")

version := "0.2.20"

lazy val root = project
  .in(file("."))
  .enablePlugins(PlayScala)
  .settings(
    libraryDependencies ++= Seq(
      ws,
      filters,
      "com.jason-goodwin" %% "authentikat-jwt" % "0.4.3",
      "org.scalatestplus" %% "play" % "1.4.0" % "test"
    ),
    resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
    resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
    resolvers += "Artifactory" at "https://flow.artifactoryonline.com/flow/libs-release/",
    credentials += Credentials(
      "Artifactory Realm",
      "flow.artifactoryonline.com",
      System.getenv("ARTIFACTORY_USERNAME"),
      System.getenv("ARTIFACTORY_PASSWORD")
    )
)

publishTo := {
  val host = "https://flow.artifactoryonline.com/flow"
  if (isSnapshot.value) {
    Some("Artifactory Realm" at s"$host/libs-snapshot-local;build.timestamp=" + new java.util.Date().getTime)
  } else {
    Some("Artifactory Realm" at s"$host/libs-release-local")
  }
}

autocommit: Update configuration to record version 0.2.20


name := "streamz"

organization in ThisBuild := "com.github.krasserm"

version in ThisBuild := "0.2-SNAPSHOT"

scalaVersion in ThisBuild := "2.11.2"

resolvers in ThisBuild += "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases"

scalacOptions in ThisBuild ++= Seq("-feature", "-language:higherKinds", "-language:implicitConversions")

libraryDependencies in ThisBuild ++= Seq(
  "org.scalaz.stream" %% "scalaz-stream" % Version.ScalazStream,
  "com.typesafe.akka" %% "akka-testkit"  % Version.Akka          % "test",
  "org.scalatest"     %% "scalatest"     % Version.Scalatest     % "test"
)

lazy val root = project.in(file(".")).aggregate(akkaCamel, akkaPersistence, akkaStream)

lazy val akkaCamel = project.in(file("streamz-akka-camel"))

lazy val akkaPersistence = project.in(file("streamz-akka-persistence"))

lazy val akkaStream = project.in(file("streamz-akka-stream"))

name := "streamz"

organization in ThisBuild := "com.github.krasserm"

version in ThisBuild := "0.3-SNAPSHOT"

scalaVersion in ThisBuild := "2.11.2"

resolvers in ThisBuild += "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases"

scalacOptions in ThisBuild ++= Seq("-feature", "-language:higherKinds", "-language:implicitConversions")

libraryDependencies in ThisBuild ++= Seq(
  "org.scalaz.stream" %% "scalaz-stream" % Version.ScalazStream,
  "com.typesafe.akka" %% "akka-testkit"  % Version.Akka          % "test",
  "org.scalatest"     %% "scalatest"     % Version.Scalatest     % "test"
)

lazy val root = project.in(file(".")).aggregate(akkaCamel, akkaPersistence, akkaStream)

lazy val akkaCamel = project.in(file("streamz-akka-camel"))

lazy val akkaPersistence = project.in(file("streamz-akka-persistence"))

lazy val akkaStream = project.in(file("streamz-akka-stream"))

Set development version to 0.3-SNAPSHOT

Set development version to 0.3-SNAPSHOT


resolvers += Classpaths.sbtPluginReleases

val branch = Process("git" :: "rev-parse" :: "--abbrev-ref" :: "HEAD" :: Nil).!!.trim
val scroogeSbtPluginVersionPrefix = "4.13.0"
val scroogeSbtPluginVersion =
  if (branch == "master") scroogeSbtPluginVersionPrefix
  else scroogeSbtPluginVersionPrefix + "-SNAPSHOT"
addSbtPlugin("com.twitter" % "scrooge-sbt-plugin" % scroogeSbtPluginVersion)

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.8.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.16")

resolvers += Classpaths.sbtPluginReleases

val branch = Process("git" :: "rev-parse" :: "--abbrev-ref" :: "HEAD" :: Nil).!!.trim
val scroogeSbtPluginVersionPrefix = "4.13.0"
val scroogeSbtPluginVersion =
  if (branch == "master") scroogeSbtPluginVersionPrefix
  else scroogeSbtPluginVersionPrefix + "-SNAPSHOT"
addSbtPlugin("com.twitter" % "scrooge-sbt-plugin" % scroogeSbtPluginVersion)

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.8.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.20")

Bump JMH version to 1.17.3

Bump JMH version to 1.17.3

Problem / Solution

The version of JMH being used was pretty long in the tooth. This bumps
us to 1.17.3.

RB_ID=903753


resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")

addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")

resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")

// cross-compiling
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject"      % "1.0.0")
addSbtPlugin("org.scala-js"       % "sbt-scalajs"                   % "0.6.32")

resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")

addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")

resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")

// cross-compiling
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject"      % "1.0.0")
addSbtPlugin("org.scala-js"       % "sbt-scalajs"                   % "0.6.33")

Update sbt-scalajs, scalajs-compiler to 0.6.33


addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.7.1")

addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.3.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.3.8")

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.4.1")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")

scalacOptions ++= Seq("-deprecation", "-feature")

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.7.1")

addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.3.5")

addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.3.8")

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.4.1")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")

scalacOptions ++= Seq("-deprecation", "-feature")

Use sbt-pack 0.3.5 to set prog.version JVM option properly


package ahlers.phantom.embedded

import java.io.File

import ahlers.phantom.embedded.parameters.IParameter
import com.google.common.collect.ImmutableList
import de.flapdoodle.embed.process.distribution.IVersion
import de.flapdoodle.embed.process.extract.IExtractedFileSet
import org.scalamock.scalatest.MockFactory
import org.scalatest.{FlatSpec, Matchers}

/**
 * @author [[mailto:michael@ahlers.consulting Michael Ahlers]]
 */
class PhantomCommandFormatterSpec
  extends FlatSpec
          with Matchers
          with MockFactory {

  it must "format files and config given argument definitions" in {
    val executable = new File("executable")

    val files = mock[IExtractedFileSet]
    (files.executable _).expects().returns(executable)

    val version = mock[IVersion]

    val config = mock[IPhantomConfig]
    (config.version _).expects().returns(version)

    val applicable = mock[IParameter]
    (applicable.format _).expects(config).returns(ImmutableList.of("applies"))

    val inapplicable = mock[IParameter]
    (inapplicable.format _).expects(*).returns(ImmutableList.of())

    val arguments = ImmutableList.of(applicable, inapplicable)

    PhantomCommandFormatter.format(arguments, files, config) should contain theSameElementsInOrderAs {
      executable.getAbsolutePath ::
        "applies" ::
        Nil
    }
  }

}

package ahlers.phantom.embedded

import java.io.File

import ahlers.phantom.embedded.parameters.IParameter
import com.google.common.collect.ImmutableList
import de.flapdoodle.embed.process.extract.IExtractedFileSet
import org.scalamock.scalatest.MockFactory
import org.scalatest.{FlatSpec, Matchers}

/**
 * @author [[mailto:michael@ahlers.consulting Michael Ahlers]]
 */
class PhantomCommandFormatterSpec
  extends FlatSpec
          with Matchers
          with MockFactory {

  it must "format files and config given argument definitions" in {
    val executable = new File("executable")

    val files = mock[IExtractedFileSet]
    (files.executable _).expects().returns(executable)

    val config = mock[IPhantomConfig]

    val applicable = mock[IParameter]
    (applicable.format _).expects(config).returns(ImmutableList.of("applies"))

    val inapplicable = mock[IParameter]
    (inapplicable.format _).expects(*).returns(ImmutableList.of())

    val arguments = ImmutableList.of(applicable, inapplicable)

    PhantomCommandFormatter.format(arguments, files, config) should contain theSameElementsInOrderAs {
      executable.getAbsolutePath ::
        "applies" ::
        Nil
    }
  }

}

Remove version (it's no longer used)

Remove version (it's no longer used)


package com.ideacolorschemes.ideacolor

import com.intellij.openapi.actionSystem.{AnActionEvent, AnAction}
import com.intellij.openapi.editor.colors.{EditorColorsScheme, EditorColorsManager}
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.project.Project

/**
 * @author il
 */

class UploadCurrentColorSchemeAction extends AnAction {
  def ideaEditorColorsManager = EditorColorsManager.getInstance

  def actionPerformed(anActionEvent: AnActionEvent) {
    implicit val project = anActionEvent.getProject
    val editorColorsScheme = ideaEditorColorsManager.getGlobalScheme
    if (ideaEditorColorsManager.isDefaultScheme(editorColorsScheme)) {
      Messages.showInfoMessage(project, "Current color scheme is default.", "Failure")
    } else {
      uploadScheme(editorColorsScheme)
    }
  }

  def uploadScheme(editorColorsScheme: EditorColorsScheme)(implicit project: Project) {
    val colorScheme = ColorSchemeParser.parse(editorColorsScheme).get
    SiteUtil.accessToSiteWithModalProgress {
      indicator => {
        indicator.setText("Trying to update current color scheme to ideacolorschemes")
        SiteServices.addScheme(colorScheme)
      }
    } match {
      case Some(url) =>
        BrowserUtil.launchBrowser(url)
      case None =>
        Messages.showInfoMessage(project, "Cannot update current color scheme to ideacolorschemes.", "Failure")
    }
  }
}

package com.ideacolorschemes.ideacolor

import com.intellij.openapi.actionSystem.{AnActionEvent, AnAction}
import com.intellij.openapi.editor.colors.{EditorColorsScheme, EditorColorsManager}
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.project.Project

/**
 * @author il
 */

class UploadCurrentColorSchemeAction extends AnAction with IdeaSchemeNameUtil {
  def ideaEditorColorsManager = EditorColorsManager.getInstance

  def actionPerformed(anActionEvent: AnActionEvent) {
    implicit val project = anActionEvent.getProject
    val editorColorsScheme = ideaEditorColorsManager.getGlobalScheme
    if (ideaEditorColorsManager.isDefaultScheme(editorColorsScheme)) {
      Messages.showInfoMessage(project, "Current color scheme is default.", "Failure")
    } else if (isBook(editorColorsScheme)) {
      Messages.showInfoMessage(project, "Current color scheme is from website.", "Failure")
    } else {
      uploadScheme(editorColorsScheme)
    }
  }

  def uploadScheme(editorColorsScheme: EditorColorsScheme)(implicit project: Project) {
    val colorScheme = ColorSchemeParser.parse(editorColorsScheme).get
    SiteUtil.accessToSiteWithModalProgress {
      indicator => {
        indicator.setText("Trying to update current color scheme to ideacolorschemes")
        SiteServices.addScheme(colorScheme)
      }
    } match {
      case Some(url) =>
        BrowserUtil.launchBrowser(url)
      case None =>
        Messages.showInfoMessage(project, "Cannot update current color scheme to ideacolorschemes.", "Failure")
    }
  }
}

Check if it's a book when upload current schemes.


package org.jetbrains.plugins.scala.lang.psi.api.base

import org.jetbrains.plugins.scala.lang.psi.types.ScType
import org.jetbrains.plugins.scala.lang.psi.types.result._

/**
  * @author adkozlov
  */
package object types {

  implicit class ScTypeElementExt(private val typeElement: ScTypeElement) extends AnyVal {
    def calcType: ScType = typeElement.`type`().getOrAny

    def getParamTypeText: String =
      if (typeElement.isRepeated) s"_root_.scala.collection.Seq[${typeElement.getText}]"
      else                        typeElement.getText
  }
}

package org.jetbrains.plugins.scala.lang.psi.api.base

import org.jetbrains.plugins.scala.lang.psi.types.ScType
import org.jetbrains.plugins.scala.lang.psi.types.result._

/**
  * @author adkozlov
  */
package object types {

  implicit class ScTypeElementExt(private val typeElement: ScTypeElement) extends AnyVal {
    def calcType: ScType = typeElement.`type`().getOrAny

    def getParamTypeText: String =
      if (typeElement.isRepeated) s"_root_.scala.Seq[${typeElement.getText}]"
      else                        typeElement.getText
  }
}

Fix type of vararg parameter type elements (now designates to scala.Seq)


package com.eneco.trading.kafka.connect.twitter

import scala.collection.JavaConverters._

/**
  * Created by andrew@datamountaineer.com on 29/02/16.
  * kafka-connect-twitter
  */
class TestTwitterSourceConnector extends TestTwitterBase {
  val goodProps = getConfig
  val badProps = goodProps + (TwitterSourceConfig.BATCH_SIZE -> "this is no integer")

  test("A TwitterSourceConnector should start with valid properties") {
    val t = new TwitterSourceConnector()
    t.start(goodProps.asJava)
  }

  test("A TwitterSourceConnector shouldn't start with invalid properties") {
    val t = new TwitterSourceConnector()
    an[Exception] should be thrownBy {
      t.start(badProps.asJava)
    }
  }

  test("A TwitterSourceConnector should provide the correct taskClass") {
    val t = new TwitterSourceConnector()
    t.taskClass() should be (classOf[TwitterSourceTask])
  }
}

package com.eneco.trading.kafka.connect.twitter

import org.apache.kafka.connect.errors.ConnectException

import scala.collection.JavaConverters._

/**
  * Created by andrew@datamountaineer.com on 29/02/16.
  * kafka-connect-twitter
  */
class TestTwitterSourceConnector extends TestTwitterBase {
  val goodProps = getConfig
  val badProps = goodProps + (TwitterSourceConfig.BATCH_SIZE -> "this is no integer")

  test("A TwitterSourceConnector should start with valid properties") {
    val t = new TwitterSourceConnector()
    t.start(goodProps.asJava)
  }

  test("A TwitterSourceConnector shouldn't start with invalid properties") {
    val t = new TwitterSourceConnector()
    a[ConnectException] should be thrownBy {
      t.start(badProps.asJava)
    }
  }

  test("A TwitterSourceConnector should provide the correct taskClass") {
    val t = new TwitterSourceConnector()
    t.taskClass() should be (classOf[TwitterSourceTask])
  }
}

Make TwitterSourceConnector property more precise


package core

import com.datastax.driver.core.{ProtocolOptions, Session, Cluster}
import org.specs2.specification.{SpecificationStructure, Fragments, Step}
import scala.io.Source
import java.io.File
import akka.actor.ActorSystem

trait TestCassandraCluster extends CassandraCluster {
  def system: ActorSystem

  private def config = system.settings.config

  import scala.collection.JavaConversions._
  private val cassandraConfig = config.getConfig("akka-cassandra.test.db.cassandra")
  private val port = cassandraConfig.getInt("port")
  private val hosts = cassandraConfig.getStringList("hosts").toList

  lazy val cluster: Cluster =
    Cluster.builder().
      addContactPoints(hosts: _*).
      withPort(port).
      withCompression(ProtocolOptions.Compression.SNAPPY).
      build()

}

trait CleanCassandra extends SpecificationStructure {
  this: CassandraCluster =>

  private def runClq(session: Session, file: File): Unit = {
    val query = Source.fromFile(file).mkString
    query.split(";").foreach(session.execute)
  }

  private def runAllClqs(): Unit = {
    val session = cluster.connect(Keyspaces.akkaCassandra)
    val uri = getClass.getResource("/").toURI
    new File(uri).listFiles().foreach { file =>
      if (file.getName.endsWith(".cql")) runClq(session, file)
    }
    session.shutdown()
  }

  override def map(fs: => Fragments) = super.map(fs) insert Step(runAllClqs())
}

package core

import com.datastax.driver.core.{ProtocolOptions, Session, Cluster}
import org.specs2.specification.{SpecificationStructure, Fragments, Step}
import scala.io.Source
import java.io.File
import akka.actor.ActorSystem

trait TestCassandraCluster extends CassandraCluster {
  def system: ActorSystem

  private def config = system.settings.config

  import scala.collection.JavaConversions._
  private val cassandraConfig = config.getConfig("akka-cassandra.test.db.cassandra")
  private val port = cassandraConfig.getInt("port")
  private val hosts = cassandraConfig.getStringList("hosts").toList

  lazy val cluster: Cluster =
    Cluster.builder().
      addContactPoints(hosts: _*).
      withCompression(ProtocolOptions.Compression.SNAPPY).
      withPort(port).
      build()

}

trait CleanCassandra extends SpecificationStructure {
  this: CassandraCluster =>

  private def runCql(session: Session, file: File): Unit = {
    val query = Source.fromFile(file).mkString
    query.split(";").foreach(session.execute)
  }

  private def runAllCqls(): Unit = {
    val session = cluster.connect(Keyspaces.akkaCassandra)
    val uri = getClass.getResource("/").toURI
    new File(uri).listFiles().foreach { file =>
      if (file.getName.endsWith(".cql")) runCql(session, file)
    }
    session.close()
  }

  override def map(fs: => Fragments) = super.map(fs) insert Step(runAllCqls())
}

Refactor runAllClq to runAllCql, Invoke close instead of shutdown on session


package spies

import plm.core.model.Game
import plm.core.model.Game.GameState
import plm.core.GameStateListener

import play.api.libs.json._

import plm.core.model.lesson.Exercise
import plm.core.model.tracking.ProgressSpyListener
import plm.core.model.lesson.ExecutionProgress
import plm.core.model.lesson.ExecutionProgress._
import actors.PLMActor
import play.api.Logger

class ExecutionResultListener(plmActor: PLMActor, game: Game) extends GameStateListener {
  def stateChanged(gameState: GameState) {
    gameState match {
      case GameState.DEMO_ENDED =>
        Logger.debug("Demo Executed - Now sending the signal")
        plmActor.sendMessage("demoEnded", Json.obj())
      case GameState.EXECUTION_ENDED =>
        Logger.debug("Executed - Now sending the exercise's result")
        var exo: Exercise = game.getCurrentLesson.getCurrentExercise.asInstanceOf[Exercise]
        var msgType: Int = 0;
        if(exo.lastResult.outcome == ExecutionProgress.outcomeKind.PASS) {
          msgType = 1;
        }
        var msg: String = exo.lastResult.getMsg(game.i18n);

        var mapArgs: JsValue = Json.obj(
          "msgType" -> msgType,
          "msg" -> msg
        )

        plmActor.sendMessage("executionResult", mapArgs)
      case _ =>

    }
  }
}

package spies

import plm.core.model.Game
import plm.core.model.Game.GameState
import plm.core.GameStateListener

import play.api.libs.json._

import plm.core.model.lesson.Exercise
import plm.core.model.tracking.ProgressSpyListener
import plm.core.model.lesson.ExecutionProgress
import plm.core.model.lesson.ExecutionProgress._
import actors.PLMActor
import play.api.Logger

class ExecutionResultListener(plmActor: PLMActor, game: Game) extends GameStateListener {
  def stateChanged(gameState: GameState) {
    gameState match {
      case GameState.DEMO_ENDED =>
        Logger.debug("Demo Executed - Now sending the signal")
        plmActor.sendMessage("demoEnded", Json.obj())
      case GameState.EXECUTION_ENDED =>
        Logger.debug("Executed - Now sending the exercise's result")
        var exo: Exercise = game.getCurrentLesson.getCurrentExercise.asInstanceOf[Exercise]
        var msgType: Int = 0;
        var commonErrorID: Int = exo.lastResult.commonErrorID;
        var commonErrorText: String = exo.lastResult.commonErrorText;
        if(exo.lastResult.outcome == ExecutionProgress.outcomeKind.PASS) {
          msgType = 1;
        }
        var msg: String = exo.lastResult.getMsg(game.i18n);

        var mapArgs: JsValue = Json.obj(
          "msgType" -> msgType,
          "msg" -> msg,
          "commonErrorID" -> commonErrorID,
          "commonErrorText" -> commonErrorText
        )

        plmActor.sendMessage("executionResult", mapArgs)
      case _ =>

    }
  }
}

Add commonErrorID and commonErrorText to 'executionResult' message


package blended.updater.internal

import java.io.File
import scala.reflect.runtime.universe
import org.helgoboss.domino.DominoActivator
import akka.actor.ActorSystem
import blended.updater.Updater
import blended.container.context.ContainerIdentifierService
import blended.akka.ActorSystemAware

class BlendedUpdaterActivator extends ActorSystemAware {
  whenBundleActive {
    manageBundleActor { config =>
      log.info(s"About to start ${getClass()}")
      val configDir = config.idSvc.getContainerContext().getContainerConfigDirectory()
      val installDir = new File(config.idSvc.getContainerContext().getContainerDirectory(), "installations").getAbsoluteFile()
      val restartFramework = { () =>
        val frameworkBundle = bundleContext.getBundle(0)
        frameworkBundle.update()
      }
      val runtimeConfigRepository = ???
      val launcherConfigRepository = ???
      Updater.props(configDir, installDir, runtimeConfigRepository, launcherConfigRepository, restartFramework)
    }
  }
}

package blended.updater.internal

import java.io.File
import scala.reflect.runtime.universe
import org.helgoboss.domino.DominoActivator
import akka.actor.ActorSystem
import blended.updater.Updater
import blended.container.context.ContainerIdentifierService
import blended.akka.ActorSystemAware

class BlendedUpdaterActivator extends ActorSystemAware {
  whenBundleActive {
    setupBundleActor { config =>
      log.info(s"About to start ${getClass()}")
      val configDir = config.idSvc.getContainerContext().getContainerConfigDirectory()
      val installDir = new File(config.idSvc.getContainerContext().getContainerDirectory(), "installations").getAbsoluteFile()
      val restartFramework = { () =>
        val frameworkBundle = bundleContext.getBundle(0)
        frameworkBundle.update()
      }
      val runtimeConfigRepository = ???
      val launcherConfigRepository = ???
      Updater.props(configDir, installDir, runtimeConfigRepository, launcherConfigRepository, restartFramework)
    }
  }
}

Fix API change in ActorSystemAware

Fix API change in ActorSystemAware


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

package org.apache.flink.api.scala.migration

case class CustomCaseClass(a: String, b: Long)

case class CustomCaseClassWithNesting(a: Long, nested: CustomCaseClass)

object CustomEnum extends Enumeration {
  type CustomEnum = Value
  val ONE, TWO, THREE, FOUR = Value
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

package org.apache.flink.api.scala.migration

@SerialVersionUID(-1196651213850142840L)
case class CustomCaseClass(a: String, b: Long)

@SerialVersionUID(-4562410952220372998L)
case class CustomCaseClassWithNesting(a: Long, nested: CustomCaseClass)

@SerialVersionUID(137486769747470244L)
object CustomEnum extends Enumeration {
  type CustomEnum = Value
  val ONE, TWO, THREE, FOUR = Value
}

[FLINK-7811] Add SerialVersionUID to Scala test classes to make it work on Scala 2.12

They didn't have a SerialVersionUID before and it seems Scala 2.12
assigns different UIDs from Scala 2.11 so we have to fix them to those
that Scala 2.11 assigned automatically.


enablePlugins(ScalaJSPlugin)

organization := "com.payalabs"
name := "scalajs-react-bridge-example"
version := "0.7.1-SNAPSHOT"

crossScalaVersions := Seq("2.12.2", "2.11.12")
scalaVersion := crossScalaVersions.value.head

libraryDependencies ++= {
  val scalaJsDom = "0.9.6"
  val scalaJsReact = "1.3.1"

  Seq(
    "org.scala-lang" % "scala-reflect" % scalaVersion.value,
    "org.scala-js" %%% "scalajs-dom" % scalaJsDom,
    "com.github.japgolly.scalajs-react" %%% "core" % scalaJsReact,
    "com.github.japgolly.scalajs-react" %%% "extra" % scalaJsReact
  )
}

resolvers += Resolver.sonatypeRepo("snapshots")

enablePlugins(ScalaJSPlugin)

organization := "com.payalabs"
name := "scalajs-react-bridge-example"
version := "0.7.1-SNAPSHOT"

crossScalaVersions := Seq("2.12.8", "2.11.12")
scalaVersion := crossScalaVersions.value.head

libraryDependencies ++= {
  val scalaJsDom = "0.9.6"
  val scalaJsReact = "1.4.0"

  Seq(
    "org.scala-lang" % "scala-reflect" % scalaVersion.value,
    "org.scala-js" %%% "scalajs-dom" % scalaJsDom,
    "com.github.japgolly.scalajs-react" %%% "core" % scalaJsReact,
    "com.github.japgolly.scalajs-react" %%% "extra" % scalaJsReact
  )
}

resolvers += Resolver.sonatypeRepo("snapshots")

Update library versions in example.

Update library versions in example.


libraryDependencies ++= Seq(
  "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0",
  "org.scala-js" %% "scalajs-env-selenium"     % "1.1.1")

addSbtPlugin("ch.epfl.scala"  % "sbt-scalafix"       % "0.9.31")
addSbtPlugin("com.github.sbt" % "sbt-pgp"            % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release"        % "1.1.0")
addSbtPlugin("org.scala-js"   % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("org.scala-js"   % "sbt-scalajs"        % "1.7.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype"       % "3.9.10")

// addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.10.0")

libraryDependencies ++= Seq(
  "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0",
  "org.scala-js" %% "scalajs-env-selenium"     % "1.1.1")

addSbtPlugin("ch.epfl.scala"  % "sbt-scalafix"       % "0.9.34")
addSbtPlugin("com.github.sbt" % "sbt-pgp"            % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release"        % "1.1.0")
addSbtPlugin("org.scala-js"   % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("org.scala-js"   % "sbt-scalajs"        % "1.7.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype"       % "3.9.10")

// addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.10.0")

Update sbt-scalafix, scalafix-core to 0.9.34