package org.talkingpuffin.filter

import org.talkingpuffin.ui.LinkExtractor
import org.talkingpuffin.twitter.TwitterStatus

/**
 * Methods related to old-style (RT, via, etc.) retweets
 */
object RetweetDetector {
  private val user = LinkExtractor.usernameRegex
  private val rtUser = ("""(rt|RT|♺)\:? ?""" + user + ".*").r
  private val viaUser = (""".*\((via|VIA|Via) +""" + user + """\)""").r
  private val regexes = List(rtUser, viaUser)

  implicit def string2Retweet(text: String) = new RetweetDetector(text)
  implicit def status2Retweet(status: TwitterStatus) = new RetweetDetector(status.text)
}

class RetweetDetector(text: String) {
  def isRetweet = RetweetDetector.regexes.exists(regex => text match {
    case regex(rtSymbol, username) => true
    case _ => false
  })

  def isFromFriend(friendUsernames: List[String]) = RetweetDetector.regexes.exists(regex => text match {
    case regex(rtSymbol, username) => friendUsernames.contains(username)
    case _ => false
  })
}

package org.talkingpuffin.filter

import org.talkingpuffin.ui.LinkExtractor
import org.talkingpuffin.twitter.TwitterStatus

/**
 * Methods related to old-style (RT, via, etc.) retweets
 */
object RetweetDetector {
  private val user = LinkExtractor.usernameRegex
  private val rtUser = ("""(rt|RT|♺)\:? ?""" + user + ".*").r
  private val viaUser = (""".*\((via|VIA|Via) +""" + user + """\)""").r
  private val regexes = List(rtUser, viaUser)

  implicit def string2RetweetDetector(text: String) = new RetweetDetector(text)
  implicit def status2RetweetDetector(status: TwitterStatus) = new RetweetDetector(status.text)
}

class RetweetDetector(text: String) {
  def isRetweet = RetweetDetector.regexes.exists(regex => text match {
    case regex(_, _) => true
    case _ => false
  })

  def isFromFriend(friendUsernames: List[String]) = RetweetDetector.regexes.exists(regex => text match {
    case regex(_, username) => friendUsernames.contains(username)
    case _ => false
  })
}

Rename implicits, use _ in place of unused parameters


package fr.lium
package api

import fr.lium.model.{Female, Male, Speaker, UnknownGender, Word}
import fr.lium.util.conversion.parseFloatOption

import java.io.File
import scala.io.Source

object WordApi {

  def getWordsFromFile(file: File): List[Word] =
    getWordsFromLines(Source.fromFile(file).getLines.toList)

  def getWordsFromLines(lines: String): List[Word] =
    getWordsFromLines(lines.split("\n").toList)

  def getWordsFromLines(lines: List[String]): List[Word] =
    lines.flatMap(getWordFromLine)

  def getWordFromLine(line: String): Option[Word] = {
    val v: List[String] = line.split(" ").toList

    v match {
        case List(show, _, start, duration, word, score, gender, channel, spkId) => Some(
          Word(show,
            parseFloatOption(start) getOrElse(0),
            parseFloatOption(duration) getOrElse(0),
            word,
            parseFloatOption(score) getOrElse(0),
            (gender, channel, spkId) match {
              case ("N/A","N/A","N/A") => None
              case (gender, channel, spkId)=> Some(Speaker(spkId, channel, gender match {
                case "M" => Male
                case "F" => Female
                case _ => UnknownGender
              }))
            }))
        case _ => None
    }
  }
}

package fr.lium
package api

import fr.lium.model.{Female, Male, Speaker, UnknownGender, Word}
import fr.lium.util.conversion.parseFloatOption

import java.io.File
import scala.io.Source
import scala.util.{Failure, Success, Try}

object WordApi {

  def getWordsFromFile(file: File): List[Word] =
    Try(getWordsFromLines(Source.fromFile(file).getLines.toList)) match {
      case Success(w) => w
      case Failure(_) => Nil
    }

  def getWordsFromLines(lines: String): List[Word] =
    getWordsFromLines(lines.split("\n").toList)

  def getWordsFromLines(lines: List[String]): List[Word] =
    lines.flatMap(getWordFromLine)

  def getWordFromLine(line: String): Option[Word] = {
    val v: List[String] = line.split(" ").toList

    v match {
        case List(show, _, start, duration, word, score, gender, channel, spkId) => Some(
          Word(show,
            parseFloatOption(start) getOrElse(0),
            parseFloatOption(duration) getOrElse(0),
            word,
            parseFloatOption(score) getOrElse(0),
            (gender, channel, spkId) match {
              case ("N/A","N/A","N/A") => None
              case (gender, channel, spkId)=> Some(Speaker(spkId, channel, gender match {
                case "M" => Male
                case "F" => Female
                case _ => UnknownGender
              }))
            }))
        case _ => None
    }
  }
}

Return an empty word list when the file cannot be found


package org.http4s
package server
package staticcontent

import java.util.concurrent.ExecutorService

import org.http4s.server._
import org.http4s.{Response, Request, StaticFile}

import scalaz.concurrent.{Strategy, Task}

object ResourceService {

  /** [[ResourceService]] configuration
    *
    * @param basePath prefix of the path files will be served from
    * @param pathPrefix prefix of the Uri that content will be served from
    * @param bufferSize size hint of internal buffers to use when serving resources
    * @param executor [[ExecutorService]] to use when collecting content
    * @param cacheStartegy strategy to use for caching purposes. Default to no caching.
    */
  case class Config(basePath: String,
                    pathPrefix: String = "",
                    bufferSize: Int = 50*1024,
                    executor: ExecutorService = Strategy.DefaultExecutorService,
                    cacheStartegy: CacheStrategy = NoopCacheStrategy)

  /** Make a new [[org.http4s.server.HttpService]] that serves static files. */
  private[staticcontent] def apply(config: Config): Service[Request, Response] = Service.lift { req =>
    val uriPath = req.pathInfo
    if (!uriPath.startsWith(config.pathPrefix))
      HttpService.notFound
    else
      StaticFile.fromResource(sanitize(config.basePath + '/' + getSubPath(uriPath, config.pathPrefix)))
        .fold(HttpService.notFound)(config.cacheStartegy.cache(uriPath, _))
  }
}

package org.http4s
package server
package staticcontent

import java.util.concurrent.ExecutorService

import org.http4s.server._
import org.http4s.{Response, Request, StaticFile}

import scalaz.concurrent.{Strategy, Task}

object ResourceService {

  /** [[ResourceService]] configuration
    *
    * @param basePath prefix of the path files will be served from
    * @param pathPrefix prefix of the Uri that content will be served from
    * @param bufferSize size hint of internal buffers to use when serving resources
    * @param executor [[ExecutorService]] to use when collecting content
    * @param cacheStartegy strategy to use for caching purposes. Default to no caching.
    */
  case class Config(basePath: String,
                    pathPrefix: String = "",
                    bufferSize: Int = 50*1024,
                    executor: ExecutorService = Strategy.DefaultExecutorService,
                    cacheStartegy: CacheStrategy = NoopCacheStrategy)

  /** Make a new [[org.http4s.HttpService]] that serves static files. */
  private[staticcontent] def apply(config: Config): Service[Request, Response] = Service.lift { req =>
    val uriPath = req.pathInfo
    if (!uriPath.startsWith(config.pathPrefix))
      HttpService.notFound
    else
      StaticFile.fromResource(sanitize(config.basePath + '/' + getSubPath(uriPath, config.pathPrefix)))
        .fold(HttpService.notFound)(config.cacheStartegy.cache(uriPath, _))
  }
}

Fix broken link in scaladoc.

Fix broken link in scaladoc.


package cook.config.runner.buildin

import scala.collection.mutable.HashMap

import java.io.File

import cook.config.runner.EvalException
import cook.config.runner.Scope
import cook.config.runner.unit._
import cook.config.runner.value._
import cook.target.Target
import cook.target.TargetManager
import cook.util.FileUtil

/**
 * Buildin function echo.
 *
 * return none
 *
 * Example:
 *
 * echo("hello")
 */
object Echo extends RunnableFuncDef("echo", Scope.ROOT_SCOPE, EchoArgsDef(), null, null) {

  override def run(path: String, argsValue: ArgsValue): Value = {
    val message = getStringOrError(argsValue.get("message"))
    println(message)

    NullValue()
  }
}

object EchoArgsDef {

  def apply(): ArgsDef = {
    val names = Seq[String]("message")
    val defaultValues = new HashMap[String, Value]

    new ArgsDef(names, defaultValues)
  }
}

package cook.config.runner.buildin

import scala.collection.mutable.HashMap

import java.io.File

import cook.config.runner.EvalException
import cook.config.runner.Scope
import cook.config.runner.unit._
import cook.config.runner.value._
import cook.target.Target
import cook.target.TargetManager
import cook.util.FileUtil

/**
 * Buildin function echo.
 *
 * return none
 *
 * Example:
 *
 * echo("hello")
 */
object Echo extends RunnableFuncDef("echo", Scope.ROOT_SCOPE, EchoArgsDef(), null, null) {

  override def run(path: String, argsValue: ArgsValue): Value = {
    val message = getOrError(argsValue.get("message")).toString
    println(message)

    NullValue()
  }
}

object EchoArgsDef {

  def apply(): ArgsDef = {
    val names = Seq[String]("message")
    val defaultValues = new HashMap[String, Value]

    new ArgsDef(names, defaultValues)
  }
}

Support all value in echo

Support all value in echo


import com.typesafe.sbt.SbtPgp.PgpKeys._
import sbtrelease.ReleasePlugin._
import sbtrelease.ReleasePlugin.ReleaseKeys._

object Release {

  lazy val settings = releaseSettings ++ Seq(
    crossBuild := false,
    publishArtifactsAction := publishSigned.value
  )

}

import scala.util.Properties.propOrEmpty

import com.typesafe.sbt.SbtPgp.PgpKeys._
import sbtrelease.ReleasePlugin._
import sbtrelease.ReleasePlugin.ReleaseKeys._

object Release {

  lazy val settings = releaseSettings ++ Seq(
    crossBuild := false,
    publishArtifactsAction := publishSigned.value,
    releaseVersion := { _ => propOrEmpty("releaseVersion")},
    nextVersion := { _ => propOrEmpty("developmentVersion")}
  )

}

Add possibility to pass release info as sys props


pomIncludeRepository := {
  x => false
}

crossPaths := false

publishTo <<= (version) apply {
  (v: String) => if (v.trim().endsWith("SNAPSHOT")) {
    Some("JavaBin Nexus repo" at "http://178.79.190.206/nexus/content/repositories/snapshots")
  }
  else {
    Some("JavaBin Nexus repo" at "http://178.79.190.206/nexus/content/repositories/releases")
  }
}

credentials += Credentials(Path.userHome / ".sbt" / "javabin.credentials")

aetherPublishBothSettings

appAssemblerSettings

appOutput in App := target.value / "appmgr" / "root"

appmgrSettings

appmgrBuild <<= appmgrBuild.dependsOn(appAssemble)

aetherArtifact <<= (aetherArtifact, appmgrBuild) map { (art, build) =>
  art.attach(build, "appmgr", "zip")
}

pomIncludeRepository := {
  x => false
}

crossPaths := false

publishTo <<= (version) apply {
  (v: String) => if (v.trim().endsWith("SNAPSHOT")) {
    Some("JavaBin Nexus repo" at "http://178.79.190.206/nexus/content/repositories/snapshots")
  }
  else {
    Some("JavaBin Nexus repo" at "http://178.79.190.206/nexus/content/repositories/releases")
  }
}

credentials += Credentials(Path.userHome / ".sbt" / "javabin.credentials")

aetherPublishBothSettings

appAssemblerSettings

appOutput in App := target.value / "appmgr" / "root"

appmgrSettings

appmgrBuild <<= appmgrBuild.dependsOn(appAssemble)

appmgrLauncher in Appmgr := (appmgrLauncher in Appmgr).value.map(_.copy(command = "jetty", name = "ems"))

aetherArtifact <<= (aetherArtifact, appmgrBuild) map { (art, build) =>
  art.attach(build, "appmgr", "zip")
}

Use the jetty command, and ems for config keys


addCompilerPlugin(
  "org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full)

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

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

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

resolvers += "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/"

addCompilerPlugin(
  "org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

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

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

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

resolvers += "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/"

Update scala macros paradise version.

Update scala macros paradise version.


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

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

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

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

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

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

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

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

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.9")

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

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

addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.12")

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

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

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

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

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

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

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

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

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

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.9")

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

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

addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.12")

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

Update sbt-scalajs, scalajs-compiler to 0.6.29


import scala.util.Properties

credentials ++= {
  (for {
  username <- Properties.envOrNone("NEXUS_USERNAME")
  password <- Properties.envOrNone("NEXUS_PASSWORD")
} yield
  Credentials(
    "Sonatype Nexus Repository Manager",
    "oss.sonatype.org",
    username,
    password
  )).toSeq
}

import scala.util.Properties

credentials ++= {
  (for {
  username <- Properties.envOrNone("NEXUS_USERNAME")
  password <- Properties.envOrNone("NEXUS_PASSWORD")
} yield
  Credentials(
    "Sonatype Nexus Repository Manager",
    "nye.java.no",
    username,
    password
  )).toSeq
}

Make sure we are using the correct host

Make sure we are using the correct host


package xt.server

import java.net.InetSocketAddress
import java.util.concurrent.Executors

import org.jboss.netty.bootstrap.ServerBootstrap
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory

import xt.middleware.App

class Server(app: App) {
  def start {
    val bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool, Executors.newCachedThreadPool))
    bootstrap.setPipelineFactory(new ChannelPipelineFactory(app))
    bootstrap.setOption("reuseAddress", true)
    bootstrap.setOption("child.tcpNoDelay", true)
    bootstrap.setOption("child.keepAlive",  true)
    bootstrap.bind(new InetSocketAddress(8080))
  }
}

package xt.server

import java.net.InetSocketAddress
import java.util.concurrent.Executors

import org.jboss.netty.bootstrap.ServerBootstrap
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory

import xt.middleware.App

class Server(app: App, port: Int) {
  def start {
    val bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool, Executors.newCachedThreadPool))
    bootstrap.setPipelineFactory(new ChannelPipelineFactory(app))
    bootstrap.setOption("reuseAddress", true)
    bootstrap.setOption("child.tcpNoDelay", true)
    bootstrap.setOption("child.keepAlive",  true)
    bootstrap.bind(new InetSocketAddress(port))
  }
}

Allow application to config web server port


package cpup.mc.lib.util.pos

import net.minecraft.world.World
import net.minecraft.block.Block
import cpup.mc.lib.util.Direction

case class BlockPos(world: World, x: Int, y: Int, z: Int) {
	def setBlock(block: Block) = {
		world.setBlock(x, y, z, block)

		this
	}

	def setMetadata(meta: Int, notify: Int) = {
		world.setBlockMetadataWithNotify(x, y, z, meta, notify)

		this
	}

	def block = world.getBlock(x, y, z)
	def metadata = world.getBlockMetadata(x, y, z)

	def offset(offsetX: Int, offsetY: Int, offsetZ: Int) = BlockPos(world, x + offsetX, y + offsetY, z + offsetZ)
	def offset(dir: Direction, dist: Int = 1): BlockPos = offset(dir.forgeDir.offsetX * dist, dir.forgeDir.offsetY * dist, dir.forgeDir.offsetZ * dist)

	def isAir = block.isAir(world, x, y, z)
	def isReplaceable = block.isReplaceable(world, x, y, z)
}

package cpup.mc.lib.util.pos

import net.minecraft.world.World
import net.minecraft.block.Block
import cpup.mc.lib.util.Direction

case class BlockPos(world: World, x: Int, y: Int, z: Int) {
	def setBlock(block: Block) = {
		world.setBlock(x, y, z, block)

		this
	}

	def setMetadata(meta: Int, notify: Int) = {
		world.setBlockMetadataWithNotify(x, y, z, meta, notify)

		this
	}

	def block = world.getBlock(x, y, z)
	def metadata = world.getBlockMetadata(x, y, z)
	def tileEntity = world.getTileEntity(x, y, z)

	def offset(offsetX: Int, offsetY: Int, offsetZ: Int) = BlockPos(world, x + offsetX, y + offsetY, z + offsetZ)
	def offset(dir: Direction, dist: Int = 1): BlockPos = offset(dir.forgeDir.offsetX * dist, dir.forgeDir.offsetY * dist, dir.forgeDir.offsetZ * dist)

	def isAir = block.isAir(world, x, y, z)
	def isReplaceable = block.isReplaceable(world, x, y, z)
}

Add helper for getting the tile entity

Add helper for getting the tile entity


package com.socrata.http.server.util

import javax.servlet.http.HttpServletRequest
import org.slf4j.MDC

/**
 * Utilities for obtaining a universal request ID for socrata-http apps.
 */
object RequestId {
  type RequestId = String

  val ReqIdHeader = "X-Socrata-RequestId"
  private val secureRandom = new java.security.SecureRandom

  /**
   * Obtains a RequestId from an HTTP request, generating one if not present.
   * Also inserts the RequestId into MDC for logging if not present.
   * @param req the [[HttpServletRequest]] object
   * @return the RequestId from the request or a generated one
   */
  def getFromRequest(req: HttpServletRequest): RequestId =
    Option(req.getHeader(ReqIdHeader)).getOrElse(generateAndPut())

  /**
   * Generates a random Request ID.
   * NOTE: this is probably good enough but should we consider using UUIDs?
   */
  def generate(): RequestId = math.BigInt(128, secureRandom).toString(36)

  private def generateAndPut(): RequestId = {
    val reqId = generate()
    MDC.put(ReqIdHeader, reqId)
    reqId
  }
}

package com.socrata.http.server.util

import javax.servlet.http.HttpServletRequest
import org.slf4j.MDC

/**
 * Utilities for obtaining a universal request ID for socrata-http apps.
 */
object RequestId {
  type RequestId = String

  val ReqIdHeader = "X-Socrata-RequestId"
  private val secureRandom = new java.security.SecureRandom

  /**
   * Obtains a RequestId from an HTTP request, generating one if not present.
   * Also inserts the RequestId into MDC for logging if not present.
   * @param req the servlet request object
   * @return the RequestId from the request or a generated one
   */
  def getFromRequest(req: HttpServletRequest): RequestId =
    Option(req.getHeader(ReqIdHeader)).getOrElse(generateAndPut())

  /**
   * Generates a random Request ID.
   * NOTE: this is probably good enough but should we consider using UUIDs?
   */
  def generate(): RequestId = math.BigInt(128, secureRandom).toString(36)

  private def generateAndPut(): RequestId = {
    val reqId = generate()
    MDC.put(ReqIdHeader, reqId)
    reqId
  }
}

Fix doc warning. scaladoc will already link to the type of the argument, no need to repeat it.


/*
 * 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.spark.sql

import org.apache.spark.sql.catalyst.InternalRow

/**
 * Shim to allow us to implement [[scala.Iterator]] in Java. Scala 2.11+ has an AbstractIterator
 * class for this, but that class is `private[scala]` in 2.10. We need to explicitly fix this to
 * `Row` in order to work around a spurious IntelliJ compiler error.
 */
private[spark] abstract class AbstractScalaRowIterator extends Iterator[InternalRow]

/*
 * 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.spark.sql

/**
 * Shim to allow us to implement [[scala.Iterator]] in Java. Scala 2.11+ has an AbstractIterator
 * class for this, but that class is `private[scala]` in 2.10. We need to explicitly fix this to
 * `Row` in order to work around a spurious IntelliJ compiler error. This cannot be an abstract
 * class because that leads to compilation errors under Scala 2.11.
 */
private[spark] class AbstractScalaRowIterator[T] extends Iterator[T] {
  override def hasNext: Boolean = throw new NotImplementedError

  override def next(): T = throw new NotImplementedError
}

[SPARK-9045] Fix Scala 2.11 build break in UnsafeExternalRowSorter

This fixes a compilation break in under Scala 2.11:

```
[error] /home/jenkins/workspace/Spark-Master-Scala211-Compile/sql/catalyst/src/main/java/org/apache/spark/sql/execution/UnsafeExternalRowSorter.java:135: error: <anonymous org.apache.spark.sql.execution.UnsafeExternalRowSorter$1> is not abstract and does not override abstract method <B>minBy(Function1<InternalRow,B>,Ordering<B>) in TraversableOnce
[error]       return new AbstractScalaRowIterator() {
[error]                                             ^
[error]   where B,A are type-variables:
[error]     B extends Object declared in method <B>minBy(Function1<A,B>,Ordering<B>)
[error]     A extends Object declared in interface TraversableOnce
[error] 1 error
```

The workaround for this is to make `AbstractScalaRowIterator` into a concrete class.

Author: Josh Rosen <joshrosen@databricks.com>

Closes #7405 from JoshRosen/SPARK-9045 and squashes the following commits:

cbcbb4c [Josh Rosen] Forgot that we can't use the ??? operator anymore
577ba60 [Josh Rosen] [SPARK-9045] Fix Scala 2.11 build break in UnsafeExternalRowSorter.


import sbt._, Keys._

object Dependencies {
  val servletApiDep = "jakarta.servlet" % "jakarta.servlet-api" % "5.0.0"

  val specs2Dep = Def.setting {
    "org.specs2" %% "specs2-core" % "4.12.12" cross CrossVersion.for3Use2_13
  }

  def okHttp = "com.squareup.okhttp3" % "okhttp" % "4.9.1" :: Nil

  def integrationTestDeps = Def.setting((specs2Dep.value :: okHttp) map { _ % "test" })

  val commonsCodecVersion = "1.15"
  val scalaXmlVersion = "2.0.1"
  val commonsIoVersion = "2.11.0"
  val commonsFileUploadVersion = "1.4"
  val jettyVersion = "11.0.6"
  val nettyVersion = "4.1.68.Final"
  val scalatestVersion = "3.2.9"
  val scalatestScalacheckVersion = "3.2.9.0"
  val json4sVersion = "4.0.3"
  val asyncHttpClientVersion = "1.8.17"
  val javaxActivationVersion = "1.1.1"
}

import sbt._, Keys._

object Dependencies {
  val servletApiDep = "jakarta.servlet" % "jakarta.servlet-api" % "5.0.0"

  val specs2Dep = Def.setting {
    "org.specs2" %% "specs2-core" % "4.12.12" cross CrossVersion.for3Use2_13
  }

  def okHttp = "com.squareup.okhttp3" % "okhttp" % "4.9.1" :: Nil

  def integrationTestDeps = Def.setting((specs2Dep.value :: okHttp) map { _ % "test" })

  val commonsCodecVersion = "1.15"
  val scalaXmlVersion = "2.0.1"
  val commonsIoVersion = "2.11.0"
  val commonsFileUploadVersion = "1.4"
  val jettyVersion = "11.0.6"
  val nettyVersion = "4.1.68.Final"
  val scalatestVersion = "3.2.10"
  val scalatestScalacheckVersion = "3.2.9.0"
  val json4sVersion = "4.0.3"
  val asyncHttpClientVersion = "1.8.17"
  val javaxActivationVersion = "1.1.1"
}

Update scalatest, scalatest-core to 3.2.10


package examples

object sort2 {

  def sort(a: List[Int]): List[Int] = {
    if (a.length < 2)
      a
    else {
      val pivot = a(a.length / 2)
      def lePivot(x: Int) = x < pivot
      def gtPivot(x: Int) = x > pivot
      def eqPivot(x: Int) = x == pivot
      sort(a filter lePivot) :::
           sort(a filter eqPivot) :::
           sort(a filter gtPivot)
    }
  }

  def main(args: Array[String]) {
    val xs = List(6, 2, 8, 5, 1)
    println(xs)
    println(sort(xs))
  }

}

package examples

object sort2 {

  def sort(a: List[Int]): List[Int] = {
    if (a.length < 2)
      a
    else {
      val pivot = a(a.length / 2)
      def lePivot(x: Int) = x < pivot
      def gtPivot(x: Int) = x > pivot
      def eqPivot(x: Int) = x == pivot
      sort(a filter lePivot) :::
           (a filter eqPivot) :::
           sort(a filter gtPivot)
    }
  }

  def main(args: Array[String]) {
    val xs = List(6, 2, 8, 5, 1, 8)
    println(xs)
    println(sort(xs))
  }

}

Fix bug in example sort.

Fix bug in example sort.

Embarrassing bug causes sort to explode if there are any duplicated
elements. Closes SI-4961, no review.


// Imports

import scalariform.formatter.preferences._

import de.johoop.findbugs4sbt.FindBugs._

import de.johoop.jacoco4sbt._

import JacocoPlugin._

// Global build settings

fork := true

// Scalariform - source code formatter

// disable automatic reformat on compile
// instead use 'scalariform-format' command in sbt
defaultScalariformSettings // instead of scalariformSettings

// list of preferences available at http://mdr.github.io/scalariform/
ScalariformKeys.preferences := FormattingPreferences()
  .setPreference(AlignSingleLineCaseStatements, true)
  .setPreference(DoubleIndentClassDeclaration, true)
  .setPreference(PreserveDanglingCloseParenthesis, true)

// FindBugs settings

findbugsSettings

findbugsReportType := Some(de.johoop.findbugs4sbt.ReportType.FancyHistHtml)

findbugsPriority := de.johoop.findbugs4sbt.Priority.Low

findbugsEffort := de.johoop.findbugs4sbt.Effort.Maximum

findbugsReportPath := Some(crossTarget.value / "findbugs" / "report.html")

// JacocoPlugin settings

jacoco.settings

// Imports

import scalariform.formatter.preferences._

import de.johoop.findbugs4sbt.FindBugs._

import de.johoop.jacoco4sbt._

import JacocoPlugin._

// Global build settings

// Scalariform - source code formatter

// disable automatic reformat on compile
// instead use 'scalariform-format' command in sbt
defaultScalariformSettings // instead of scalariformSettings

// list of preferences available at http://mdr.github.io/scalariform/
ScalariformKeys.preferences := FormattingPreferences()
  .setPreference(AlignSingleLineCaseStatements, true)
  .setPreference(DoubleIndentClassDeclaration, true)
  .setPreference(PreserveDanglingCloseParenthesis, true)

// FindBugs settings

findbugsSettings

findbugsReportType := Some(de.johoop.findbugs4sbt.ReportType.FancyHistHtml)

findbugsPriority := de.johoop.findbugs4sbt.Priority.Low

findbugsEffort := de.johoop.findbugs4sbt.Effort.Maximum

findbugsReportPath := Some(crossTarget.value / "findbugs" / "report.html")

// JacocoPlugin settings

jacoco.settings

Fix bug in SBT config

Fix bug in SBT config

Remove property that forks by default. This may cause problems in some
cases for certain applications, and this property should not be forced
in the global build configuration.


package japgolly.scalajs.react.internal

import scala.annotation.elidable
import scala.reflect.macros.blackbox.Context
import sourcecode.Util

trait AutoComponentName {
  def value: String
}

object AutoComponentName {

  def apply(s: => String): AutoComponentName =
    new AutoComponentName {
      @elidable(elidable.INFO)
      override def value = s
    }

  implicit def materialize: AutoComponentName =
    macro AutoComponentNameMacros.generate
}

final class AutoComponentNameMacros(val c: Context) extends MacroUtils {
  import c.universe._

  def generate: c.Expr[AutoComponentName] = {
    val owner =
      c.internal.enclosingOwner

    val name =
      owner.fullName.trim
        .split("\\.", -1)
        .iterator
        .filterNot(Util.isSyntheticName)
        .map(_.stripSuffix("$"))
        .mkString(".")

    val impl =
      q"_root_.japgolly.scalajs.react.internal.AutoComponentName($name)"

    c.Expr[AutoComponentName](impl)
  }

}

package japgolly.scalajs.react.internal

import scala.annotation.elidable
import scala.reflect.macros.blackbox.Context

trait AutoComponentName {
  def value: String
}

object AutoComponentName {

  def apply(s: => String): AutoComponentName =
    new AutoComponentName {
      @elidable(elidable.INFO)
      override def value = s
    }

  implicit def materialize: AutoComponentName =
    macro AutoComponentNameMacros.generate
}

final class AutoComponentNameMacros(val c: Context) extends MacroUtils {
  import c.universe._

  def generate: c.Expr[AutoComponentName] = {
    val owner =
      c.internal.enclosingOwner

    val name =
      owner.fullName.trim
        .split("\\.", -1)
        .iterator
        .filterNot(sourcecode.Util.isSyntheticName)
        .map(_.stripSuffix("$"))
        .mkString(".")

    val impl =
      q"_root_.japgolly.scalajs.react.internal.AutoComponentName($name)"

    c.Expr[AutoComponentName](impl)
  }

}

Fix compilation under Scala 2.12

Fix compilation under Scala 2.12


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

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

Fix incorrect ScalaJS version. Latest is 0.6.5.


scalacOptions += "-deprecation"
libraryDependencies += "org.slf4j" % "slf4j-nop" % "1.7.31"

addSbtPlugin("com.typesafe"                      % "sbt-mima-plugin"       % "0.9.2")
addSbtPlugin("com.typesafe.sbt"                  % "sbt-osgi"              % "0.9.6")
addSbtPlugin("com.eed3si9n"                      % "sbt-buildinfo"         % "0.10.0")
addSbtPlugin("com.geirsson"                      % "sbt-ci-release"        % "1.5.7")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings"      % "3.0.0")
addSbtPlugin("org.scala-js"                      % "sbt-scalajs"           % "1.6.0")
addSbtPlugin("org.scala-native"                  % "sbt-scala-native"      % "0.4.0")
addSbtPlugin("org.portable-scala"                % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala"                % "sbt-scala-native-crossproject" % "1.0.0")
addSbtPlugin("com.codecommit"                    % "sbt-github-actions"    % "0.12.0")

scalacOptions += "-deprecation"
libraryDependencies += "org.slf4j" % "slf4j-nop" % "1.7.31"

addSbtPlugin("com.typesafe"                      % "sbt-mima-plugin"       % "0.9.2")
addSbtPlugin("com.typesafe.sbt"                  % "sbt-osgi"              % "0.9.6")
addSbtPlugin("com.eed3si9n"                      % "sbt-buildinfo"         % "0.10.0")
addSbtPlugin("com.geirsson"                      % "sbt-ci-release"        % "1.5.7")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings"      % "3.0.0")
addSbtPlugin("org.scala-js"                      % "sbt-scalajs"           % "1.6.0")
addSbtPlugin("org.scala-native"                  % "sbt-scala-native"      % "0.4.0")
addSbtPlugin("org.portable-scala"                % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("org.portable-scala"                % "sbt-scala-native-crossproject" % "1.1.0")
addSbtPlugin("com.codecommit"                    % "sbt-github-actions"    % "0.12.0")

Update sbt-scala-native-crossproject, ... to 1.1.0


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

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

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")

val scalaJSVersion = Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.7.1")

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

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

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

val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.3")

addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)

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

addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.5")

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

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

addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.4")

val scalaJSVersion = Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.7.1")

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

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

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

val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.3")

addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)

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

addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.5")

Downgrade sbt-osgi to 0.9.4, to work around race condition in 0.9.5+

Ref: https://github.com/lampepfl/dotty/issues/11604

(cherry picked from commit d3b7db9af036829e417e6a08940d9e4e406cfbf2)
(cherry picked from commit 96650cfbf7003c198e2759bdca4a9a37dac03cad)


resolvers ++= Seq(
  Classpaths.sbtPluginReleases,
  Resolver.sonatypeRepo("releases"),
  Resolver.bintrayIvyRepo("jetbrains", "sbt-plugins")
)

addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.18")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")

resolvers ++= Seq(
  Classpaths.sbtPluginReleases,
  Resolver.sonatypeRepo("releases"),
  Resolver.bintrayIvyRepo("jetbrains", "sbt-plugins")
)

addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.20")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")

Update mdoc_2.12, mdoc_2.13, sbt-mdoc to 2.2.20


logLevel := Level.Warn

libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.0"
libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0"

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.6.0")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3")
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")

// Deployment configuration
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")

logLevel := Level.Warn

libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.0"
libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0"

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.3")
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")

// Deployment configuration
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")

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


addSbtPlugin("com.lightbend.paradox"     % "sbt-paradox"             % "0.9.2")
addSbtPlugin("com.typesafe.sbt"          % "sbt-site"                % "1.4.1")
addSbtPlugin("com.typesafe.sbt"          % "sbt-ghpages"             % "0.6.3")
addSbtPlugin("org.typelevel"             % "sbt-typelevel-ci-release" % "0.4.8")
addSbtPlugin("org.scoverage"             % "sbt-scoverage"           % "1.9.3")
addSbtPlugin("com.timushev.sbt"          % "sbt-updates"             % "0.6.2")
addSbtPlugin("pl.project13.scala"        % "sbt-jmh"                 % "0.4.3")
addSbtPlugin("de.heikoseeberger"         % "sbt-header"              % "5.7.0")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat"            % "0.1.21")
addSbtPlugin("org.scalameta"             % "sbt-mdoc"                % "2.2.24")

addSbtPlugin("com.lightbend.paradox"     % "sbt-paradox"             % "0.9.2")
addSbtPlugin("com.typesafe.sbt"          % "sbt-site"                % "1.4.1")
addSbtPlugin("com.typesafe.sbt"          % "sbt-ghpages"             % "0.6.3")
addSbtPlugin("org.typelevel"             % "sbt-typelevel-ci-release" % "0.4.8")
addSbtPlugin("org.scoverage"             % "sbt-scoverage"           % "1.9.3")
addSbtPlugin("com.timushev.sbt"          % "sbt-updates"             % "0.6.2")
addSbtPlugin("pl.project13.scala"        % "sbt-jmh"                 % "0.4.3")
addSbtPlugin("de.heikoseeberger"         % "sbt-header"              % "5.7.0")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat"            % "0.1.21")
addSbtPlugin("org.scalameta"             % "sbt-mdoc"                % "2.3.3")

Update mdoc, sbt-mdoc to 2.3.3

Update mdoc, sbt-mdoc to 2.3.3


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

addSbtPlugin("ch.epfl.scala"  % "sbt-scalafix"       % "0.9.27")
addSbtPlugin("com.github.sbt" % "sbt-pgp"            % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release"        % "1.0.15")
addSbtPlugin("org.scala-js"   % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("org.scala-js"   % "sbt-scalajs"        % "1.5.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype"       % "3.9.7")

// 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.0")

addSbtPlugin("ch.epfl.scala"  % "sbt-scalafix"       % "0.9.27")
addSbtPlugin("com.github.sbt" % "sbt-pgp"            % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release"        % "1.0.15")
addSbtPlugin("org.scala-js"   % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("org.scala-js"   % "sbt-scalajs"        % "1.5.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype"       % "3.9.7")

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

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


resolvers += Resolver.url("hmrc-sbt-plugin-releases", url("https://dl.bintray.com/hmrc/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

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

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.4.0")

addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "0.9.0")

addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "0.13.0")

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

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

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.6.0")

addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.8")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")

resolvers += Resolver.url("hmrc-sbt-plugin-releases", url("https://dl.bintray.com/hmrc/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

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

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.4.0")

addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "0.9.0")

addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "0.13.0")

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

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

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.6.0")

addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.8")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")

Use version 1.3.0 of sbt-scoverage

Use version 1.3.0 of sbt-scoverage


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

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")

// web plugins

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

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

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")

// Code coverage
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.3")

addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.2.0")

//docker packager
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.2")

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

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")

// web plugins

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

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

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")

// Code coverage
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.3.3")

addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.2.1")

//docker packager
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.2")

Update codify coverage report dependency


addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.5.0")

//addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")

Disable sbteclipse-plugin until it's compatible with 0.12.0-M1 or later.


scalacOptions := Seq(
  "-deprecation"
)

// For MimeLoader plugin. Dogfooding and hoping it doesn't clash with
// our other sbt plugins.
libraryDependencies ++= List(
  "com.eed3si9n" %% "treehugger" % "0.4.4",
  "io.circe" %% "circe-generic" % "0.14.1",
  "org.http4s" %% "http4s-ember-client" % "0.22.1",
  "org.http4s" %% "http4s-circe" % "0.22.1",
)

scalacOptions := Seq(
  "-deprecation"
)

// For MimeLoader plugin. Dogfooding and hoping it doesn't clash with
// our other sbt plugins.
libraryDependencies ++= List(
  "com.eed3si9n" %% "treehugger" % "0.4.4",
  "io.circe" %% "circe-generic" % "0.14.1",
  "org.http4s" %% "http4s-ember-client" % "0.22.2",
  "org.http4s" %% "http4s-circe" % "0.22.2",
)

Update http4s-circe, http4s-ember-client to 0.22.2


package org.http4s.client.blaze

import scalaz.concurrent.Task

import org.http4s._

import org.specs2.mutable.After

// TODO: this should have a more comprehensive test suite
class ExternalBlazeHttp1ClientSpec extends Http4sSpec {

  private val simpleClient = SimpleHttp1Client()

  "Blaze Simple Http1 Client" should {
    "Make simple https requests" in {
      val resp = simpleClient.expect[String](uri("https://github.com/")).run
      resp.length mustNotEqual 0
    }
  }

  step {
    simpleClient.shutdown.run
  }

  private val pooledClient = PooledHttp1Client()

  "RecyclingHttp1Client" should {
    def fetchBody = pooledClient.toService(_.as[String]).local { uri: Uri => Request(uri = uri) }

    "Make simple https requests" in {
      val resp = fetchBody.run(uri("https://github.com/")).run
      resp.length mustNotEqual 0
    }

    "Repeat a simple https request" in {
      val f = (0 until 10).map(_ => Task.fork {
        val resp = fetchBody.run(uri("https://github.com/"))
        resp.map(_.length)
      })

      foreach(Task.gatherUnordered(f).run) { length =>
        length mustNotEqual 0
      }
    }
  }

  step {
    pooledClient.shutdown.run
  }
}

package org.http4s.client.blaze

import scala.concurrent.duration._
import scalaz.concurrent.Task

import org.http4s._

import org.specs2.mutable.After

// TODO: this should have a more comprehensive test suite
class ExternalBlazeHttp1ClientSpec extends Http4sSpec {
  private val timeout = 30.seconds

  private val simpleClient = SimpleHttp1Client()

  "Blaze Simple Http1 Client" should {
    "Make simple https requests" in {
      val resp = simpleClient.expect[String](uri("https://httpbin.org/get")).runFor(timeout)
      resp.length mustNotEqual 0
    }
  }

  step {
    simpleClient.shutdown.run
  }

  private val pooledClient = PooledHttp1Client()

  "RecyclingHttp1Client" should {
    def fetchBody = pooledClient.toService(_.as[String]).local { uri: Uri => Request(uri = uri) }

    "Make simple https requests" in {
      val resp = fetchBody.run(uri("https://github.com/")).run
      resp.length mustNotEqual 0
    }

    "Repeat a simple https request" in {
      val f = (0 until 10).map(_ => Task.fork {
        val resp = fetchBody.run(uri("https://github.com/"))
        resp.map(_.length)
      })

      foreach(Task.gatherUnordered(f).run) { length =>
        length mustNotEqual 0
      }
    }
  }

  step {
    pooledClient.shutdown.run
  }
}

Use httpbin.org for Blaze client external SSL test

When `AsyncHttpClientSpec` triggers `ThreadDumpOnTimeout`, the thread
dump often shows `ExternalBlazeHttp1ClientSpec` calling github.com in
the stack.  GitHub rate limits requests from Travis CI, so switch to
https://httpbin.org/get to see if that helps avoid timeouts.
Additional detail in #909.

This is suggestion #1 from @rossabaker [from Gitter](https://gitter.im/http4s/http4s?at=58a73413aa800ee52cabed70).


import sbt._, Keys._

object Dependencies {
  val servletApiDep = "jakarta.servlet" % "jakarta.servlet-api" % "5.0.0"

  val specs2Dep = Def.setting {
    "org.specs2" %% "specs2-core" % "4.13.1" cross CrossVersion.for3Use2_13
  }

  def okHttp = "com.squareup.okhttp3" % "okhttp" % "4.9.3" :: Nil

  def integrationTestDeps = Def.setting((specs2Dep.value :: okHttp) map { _ % "test" })

  val commonsCodecVersion = "1.15"
  val scalaXmlVersion = "2.0.1"
  val commonsIoVersion = "2.11.0"
  val commonsFileUploadVersion = "1.4"
  val jettyVersion = "11.0.7"
  val nettyVersion = "4.1.71.Final"
  val scalatestVersion = "3.2.10"
  val scalatestScalacheckVersion = s"${scalatestVersion}.0"
  val json4sVersion = "4.0.3"
  val asyncHttpClientVersion = "1.8.17"
  val javaxActivationVersion = "1.1.1"
}

import sbt._, Keys._

object Dependencies {
  val servletApiDep = "jakarta.servlet" % "jakarta.servlet-api" % "5.0.0"

  val specs2Dep = Def.setting {
    "org.specs2" %% "specs2-core" % "4.13.1" cross CrossVersion.for3Use2_13
  }

  def okHttp = "com.squareup.okhttp3" % "okhttp" % "4.9.3" :: Nil

  def integrationTestDeps = Def.setting((specs2Dep.value :: okHttp) map { _ % "test" })

  val commonsCodecVersion = "1.15"
  val scalaXmlVersion = "2.0.1"
  val commonsIoVersion = "2.11.0"
  val commonsFileUploadVersion = "1.4"
  val jettyVersion = "11.0.7"
  val nettyVersion = "4.1.72.Final"
  val scalatestVersion = "3.2.10"
  val scalatestScalacheckVersion = s"${scalatestVersion}.0"
  val json4sVersion = "4.0.3"
  val asyncHttpClientVersion = "1.8.17"
  val javaxActivationVersion = "1.1.1"
}

Update netty-codec-http, netty-handler, ... to 4.1.72.Final


object Version {
  val akkaHttp        = "1.0"
  val scalaTest       = "2.2.1"
  val logback         = "1.1.2"
  val scalaLogging    = "3.1.0"
  val slick           = "3.0.1"
  val slickPG         = "0.9.1"
  val hikariCP        = "2.3.7"
  val jts             = "1.13"
  val scale           = "0.0.2"
}

object Version {
  val akkaHttp        = "2.0-M2"
  val scalaTest       = "2.2.1"
  val logback         = "1.1.2"
  val scalaLogging    = "3.1.0"
  val slick           = "3.0.1"
  val slickPG         = "0.9.1"
  val hikariCP        = "2.3.7"
  val jts             = "1.13"
  val scale           = "0.0.2"
}

Update akka streams to 2.0-M2

Update akka streams to 2.0-M2


// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.url("fix-sbt-plugin-releases", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

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

// Eclipse
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

//IntelliJ
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

Add SBT plugin for generating IntelliJ project files


logLevel := Level.Warn

libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.0"
libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0"

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.2")
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")

// Deployment configuration
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")

logLevel := Level.Warn

libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.0"
libraryDependencies += "org.scala-js" %% "scalajs-env-jsdom-nodejs" % "1.1.0"

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.2")
addSbtPlugin("org.jetbrains" % "sbt-ide-settings" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")

// Deployment configuration
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")


package org.apache.mesos.chronos.scheduler

import java.util.concurrent.atomic.AtomicBoolean
import java.util.logging.Logger

import org.apache.mesos.chronos.scheduler.api._
import org.apache.mesos.chronos.scheduler.config._
import org.apache.mesos.chronos.scheduler.jobs.{JobScheduler, MetricReporterService, ZookeeperService}
import mesosphere.chaos.http.{HttpConf, HttpModule, HttpService}
import mesosphere.chaos.metrics.MetricsModule
import mesosphere.chaos.{App, AppConfiguration}
import org.rogach.scallop.ScallopConf

/**
 * Main entry point to chronos using the Chaos framework.
 * @author Florian Leibert (flo@leibert.de)
 */
object Main extends App {
  lazy val conf = new ScallopConf(args)
    with HttpConf with AppConfiguration with SchedulerConfiguration
    with GraphiteConfiguration with CassandraConfiguration
  val isLeader = new AtomicBoolean(false)
  private[this] val log = Logger.getLogger(getClass.getName)

  log.info("---------------------")
  log.info("Initializing chronos.")
  log.info("---------------------")

  def modules() = {
    Seq(
      new HttpModule(conf),
      new ChronosRestModule,
      new MetricsModule,
      new MainModule(conf),
      new ZookeeperModule(conf),
      new JobMetricsModule(conf),
      new JobStatsModule(conf)
    )
  }

  run(
    classOf[ZookeeperService],
    classOf[HttpService],
    classOf[JobScheduler],
    classOf[MetricReporterService]
  )
}

package org.apache.mesos.chronos.scheduler

import java.util.concurrent.atomic.AtomicBoolean
import java.util.logging.Logger

import org.apache.mesos.chronos.scheduler.api._
import org.apache.mesos.chronos.scheduler.config._
import org.apache.mesos.chronos.scheduler.jobs.{JobScheduler, MetricReporterService, ZookeeperService}
import mesosphere.chaos.http.{HttpConf, HttpModule, HttpService}
import mesosphere.chaos.metrics.MetricsModule
import mesosphere.chaos.{App, AppConfiguration}
import org.rogach.scallop.ScallopConf

/**
 * Main entry point to chronos using the Chaos framework.
 * @author Florian Leibert (flo@leibert.de)
 */
object Main extends App {
  lazy val conf = new ScallopConf(args)
    with HttpConf with AppConfiguration with SchedulerConfiguration
    with GraphiteConfiguration with CassandraConfiguration
  val isLeader = new AtomicBoolean(false)
  private[this] val log = Logger.getLogger(getClass.getName)

  log.info("---------------------")
  log.info("Initializing chronos.")
  log.info("---------------------")

  def modules() = {
    Seq(
      new HttpModule(conf),
      new ChronosRestModule,
      new MetricsModule,
      new MainModule(conf),
      new ZookeeperModule(conf),
      new JobMetricsModule(conf),
      new JobStatsModule(conf)
    )
  }

  try {
    run(
      classOf[ZookeeperService],
      classOf[HttpService],
      classOf[JobScheduler],
      classOf[MetricReporterService]
    )
  } catch {
      case _ =>
        System.exit(1)
  }
}

Add try-catch block for initialization

Add try-catch block for initialization

Chronos may be hanging when exception happens during initing. Althought
it's hard to reappear, it should be handled.


package xsbt

object TaskRunner
{
	def apply[T](node: Task[T]): T = apply(node, Runtime.getRuntime.availableProcessors)
	/** Executes work for nodes in a directed acyclic graph with root node `node`.
	* The maximum number of tasks to execute simultaneously is `maximumTasks`. */
	def apply[T](node: Task[T], maximumTasks: Int): T =
	{
		require(maximumTasks > 0)
		val compute = new Compute[Work.Job, Result] { def apply[A](w: Work.Job[A]) = w.apply }
		val strategy = new SimpleStrategy[Work[_,_]]
		val scheduler = new TaskScheduler(node, strategy, new BasicTaskListener)
		val distributor = new Distributor[ Either[ List[WorkFailure[Task[_]]], T ] , Work.Job, Result](scheduler, compute, maximumTasks)
		distributor.run().fold(failures => throw new TasksFailed(failures), identity[T])
	}
}
final case class TasksFailed(failures: List[WorkFailure[Task[_]]]) extends RuntimeException(failures.length + " failed")

package xsbt

object TaskRunner
{
	def apply[T](node: Task[T]): T = apply(node, Runtime.getRuntime.availableProcessors)
	/** Executes work for nodes in a directed acyclic graph with root node `node`.
	* The maximum number of tasks to execute simultaneously is `maximumTasks`. */
	def apply[T](node: Task[T], maximumTasks: Int): T =
	{
		require(maximumTasks > 0)
		val compute = new Compute[Work.Job, Result] { def apply[A](w: Work.Job[A]) = w.apply }
		val strategy = new SimpleStrategy[Work[_,_]]
		val scheduler = new TaskScheduler(node, strategy, new BasicTaskListener)
		val distributor = new Distributor[ Either[ List[WorkFailure[Task[_]]], T ] , Work.Job, Result](scheduler, compute, maximumTasks)
		distributor.run().fold(failures => throw new TasksFailed(failures), identity[T])
	}
}
final case class TasksFailed(failures: List[WorkFailure[Task[_]]]) extends RuntimeException(failures.length + " tasks failed")
{
	override def toString = failures.mkString(getMessage + "\n", "\n\t", "\n")
}

Add toString to TaskFailure exception

Add toString to TaskFailure exception


package org.scalatest.tools

import org.scalatest.Spec
import org.scalatest.matchers.ShouldMatchers

class SbtCommandParserSpec extends Spec with ShouldMatchers {

  describe("the cmd terminal?") {
    it("should parse 'st'") {

      val parser = new SbtCommandParser
      val result = parser.parseResult("""st""")
      result match {
        case parser.Success(result, _) => println("success: " + result)
        case ns: parser.NoSuccess => fail(ns.toString)
      }
    }
    it("should parse 'st --'") {

      val parser = new SbtCommandParser
      val result = parser.parseResult("""st --""")
      result match {
        case parser.Success(result, _) => println("success: " + result)
        case ns: parser.NoSuccess => fail(ns.toString)
      }
    }
  }
}

package org.scalatest.tools

import org.scalatest.Spec
import org.scalatest.matchers.ShouldMatchers

class SbtCommandParserSpec extends Spec with ShouldMatchers {

  val parser = new SbtCommandParser

  def canParsePhrase(s: String) {
      val result = parser.parseResult(s)
      result match {
        case ns: parser.NoSuccess => fail(ns.toString)
        case _ =>
      }
  }

  def cannotParsePhrase(s: String) {
      val result = parser.parseResult(s)
      result match {
        case parser.Success(result, _) => fail("wasn't supposed to, but parsed: " + result)
        case _ =>
      }
  }

  describe("the cmd terminal?") {
    it("should parse 'st'") {
      canParsePhrase("""st""")
      canParsePhrase("""st --""")
    }
  }
}

Reduce code dup in test.

Reduce code dup in test.

git-svn-id: a9cb476116504f49bf91a09a9abbac08fcf3bbcc@3076 fd1274fd-080f-5963-8033-43ee40fcd1de


package lib

import com.gilt.apidocgenerator.models.Container

case class ExampleService(key: String) {

  val docsUrl = s"/gilt/$key/latest"
  val apiJsonUrl = s"/gilt/$key/latest/api.json"

}

object Util {

  val AddServiceText = "Add Service"
  val OrgSettingsText = "Org Settings"

  val ApidocExample = ExampleService("apidoc")
  val ApidocGeneratorExample = ExampleService("apidoc-generator")
  val Examples = Seq(ApidocExample, ApidocGeneratorExample)

  val GitHubUrl = "https://github.com/gilt/apidoc"

  def calculateNextVersion(version: String): String = {
    version.split(VersionTag.Dash).size match {
      case 1 => {
        val pieces = version.split(VersionTag.Dot)
        if (pieces.forall(s => VersionTag.isDigit(s))) {
          (Seq(pieces.last.toInt + 1) ++ pieces.reverse.drop(1)).reverse.mkString(".")
        } else {
          version
        }
      }
      case _ => version
    }
  }

  def formatType(container: Container, name: String) = {
    container match {
      case Container.Singleton => name
      case Container.List => s"[$name]"
      case Container.Map => s"map[$name]"
      case Container.UNDEFINED(container) => s"$container[$name]"
    }
  }

}

package lib

import com.gilt.apidocgenerator.models.Container

case class ExampleService(key: String) {

  val docsUrl = s"/gilt/$key/latest"
  val apiJsonUrl = s"/gilt/$key/latest/api.json"

}

object Util {

  val AddServiceText = "Add Service"
  val OrgSettingsText = "Org Settings"

  val ApidocExample = ExampleService("apidoc")
  val ApidocGeneratorExample = ExampleService("apidoc-generator")
  val ApidocSpecExample = ExampleService("apidoc-spec")
  val Examples = Seq(ApidocExample, ApidocGeneratorExample, ApidocSpecExample)

  val GitHubUrl = "https://github.com/gilt/apidoc"

  def calculateNextVersion(version: String): String = {
    version.split(VersionTag.Dash).size match {
      case 1 => {
        val pieces = version.split(VersionTag.Dot)
        if (pieces.forall(s => VersionTag.isDigit(s))) {
          (Seq(pieces.last.toInt + 1) ++ pieces.reverse.drop(1)).reverse.mkString(".")
        } else {
          version
        }
      }
      case _ => version
    }
  }

  def formatType(container: Container, name: String) = {
    container match {
      case Container.Singleton => name
      case Container.List => s"[$name]"
      case Container.Map => s"map[$name]"
      case Container.UNDEFINED(container) => s"$container[$name]"
    }
  }

}

Add apidoc-spec to public examples

Add apidoc-spec to public examples


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.7"

crossScalaVersions := Seq("2.11.7")

version := "0.0.38"

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.40"

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.40


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-lint"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.31"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.2",
      "com.ning" % "async-http-client" % "1.9.38",
      "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")
  }
}

import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-lint"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.32"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.2",
      "com.ning" % "async-http-client" % "1.9.38",
      "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.32


scalaVersion in ThisBuild := "2.10.4"

version in ThisBuild := "0.5.0-SNAPSHOT"

organization in ThisBuild := "org.squbs"

publishArtifact := false

lazy val unicomplex = project

lazy val zkcluster = project dependsOn unicomplex

lazy val testkit = project dependsOn unicomplex

scalaVersion in ThisBuild := "2.10.4"

version in ThisBuild := "0.5.0-SNAPSHOT"

organization in ThisBuild := "org.squbs"

publishArtifact := false

addCommandAlias("coverage", "scoverage:test")

lazy val unicomplex = project

lazy val zkcluster = project dependsOn unicomplex

lazy val testkit = project dependsOn unicomplex

Change alias to coverage to make jenkins coverage work always without any further changes to task name.


name := """play-auth"""

homepage := Some(url("https://gitlab.com/jasperdenkers/play-auth"))

licenses := Seq("MIT" -> url("https://opensource.org/licenses/mit-license"))

libraryDependencies ++= Seq(
  // Testing
  "org.scalatestplus.play" %% "scalatestplus-play" % "1.5.1" % Test
)

publishTo := {
  val nexus = "https://oss.sonatype.org/"
  if (isSnapshot.value)
    Some("snapshots" at nexus + "content/repositories/snapshots")
  else
    Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

publishMavenStyle := true

publishArtifact in Test := false

pomIncludeRepository := { _ => false }

pomExtra := (
  <scm>
    <url>git@gitlab.com:jasperdenkers/play-auth.git</url>
    <connection>scm:git:git@gitlab.com:jasperdenkers/play-auth.git</connection>
    <developerConnection>scm:git:git@gitlab.com:jasperdenkers/play-auth.git</developerConnection>
  </scm>
  <developers>
    <developer>
      <id>jasperdenkers</id>
      <name>Jasper Denkers</name>
      <url>http://jasperdenkers.com</url>
    </developer>
  </developers>
)

import ReleaseTransformations._

releaseProcess := Seq[ReleaseStep](
  checkSnapshotDependencies,
  inquireVersions,
  runClean,
  runTest,
  setReleaseVersion,
  commitReleaseVersion,
  tagRelease,
  ReleaseStep(action = Command.process("publishSigned", _)),
  setNextVersion,
  commitNextVersion,
  ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
  pushChanges
)

Integrate sbt-sonatype's publishSigned and sonatypeReleaseAll with sbt-release


package database

import anorm.SQL
import anorm.SqlParser._
import play.api.Play.current
import play.api.db.DB
import play.api.libs.json._

object Pending {
  def save(target: String, message: String) = DB.withConnection { implicit c =>
    SQL("INSERT INTO pending VALUES (DEFAULT, {target}, {message})")
    .on(
      'target -> target,
      'message -> message
    )
    .executeInsert()
  }

  def list() = DB.withConnection { implicit c =>
    val toSend = SQL("SELECT * FROM pending").list(
      long("id") ~
      str("target") ~
      str("message") map(flatten)
    )

    val maxId = toSend.map(_._1).max
    SQL("DELETE FROM pending WHERE id <= ?")
      .on('id -> maxId)
      .executeUpdate()

    toSend.map { case (_, target, message) =>
      Json.obj(
        "target" -> target,
        "message" -> message
      )
    }
  }
}

package database

import anorm.SQL
import anorm.SqlParser._
import play.api.Play.current
import play.api.db.DB
import play.api.libs.json._

object Pending {
  def save(target: String, message: String) = DB.withConnection { implicit c =>
    SQL("INSERT INTO pending VALUES (DEFAULT, {target}, {message})")
    .on(
      'target -> target,
      'message -> message
    )
    .executeInsert()
  }

  def list() = DB.withConnection { implicit c =>
    val toSend = SQL("SELECT * FROM pending").list(
      long("id") ~
      str("target") ~
      str("message") map(flatten)
    )

    if(toSend.size > 0) {
      val maxId = toSend.map(_._1).max
      SQL("DELETE FROM pending WHERE id <= {id}")
      .on('id -> maxId)
      .executeUpdate()
    }

    toSend.map { case (_, target, message) =>
      Json.obj(
        "target" -> target,
        "message" -> message
      )
    }
  }
}

Fix some issues with polling for pending

* max id field wasn't referenced in template
* only attempt to delete when there are actually messages


package xitrum.annotation

import scala.annotation.StaticAnnotation

sealed trait Cache extends StaticAnnotation

case class CacheActionDay   (days:    Int) extends Cache
case class CacheActionHour  (hours:   Int) extends Cache
case class CacheActionMinute(minutes: Int) extends Cache
case class CacheActionSecond(seconds: Int) extends Cache

case class CachePageDay   (hours:   Int) extends Cache
case class CachePageHour  (days:    Int) extends Cache
case class CachePageMinute(minutes: Int) extends Cache
case class CachePageSecond(seconds: Int) extends Cache

package xitrum.annotation

import scala.annotation.StaticAnnotation

sealed trait Cache extends StaticAnnotation

case class CacheActionDay   (days:    Int) extends Cache
case class CacheActionHour  (hours:   Int) extends Cache
case class CacheActionMinute(minutes: Int) extends Cache
case class CacheActionSecond(seconds: Int) extends Cache

case class CachePageDay   (days:    Int) extends Cache
case class CachePageHour  (hours:   Int) extends Cache
case class CachePageMinute(minutes: Int) extends Cache
case class CachePageSecond(seconds: Int) extends Cache

Fix minor typo at CachePageDay and CachePageHour


package controllers.disposal_of_vehicle

import play.api.mvc._
import play.api.Logger
import mappings.disposal_of_vehicle.Dispose._
import mappings.disposal_of_vehicle.VehicleLookup._
import mappings.disposal_of_vehicle.SetupTradeDetails._
import mappings.disposal_of_vehicle.TraderDetails._
import mappings.disposal_of_vehicle.BusinessChooseYourAddress._
import utils.helpers.CryptoHelper

class BeforeYouStart extends Controller {

  def present = Action { implicit request =>

    Ok(views.html.disposal_of_vehicle.before_you_start()).withNewSession.
      discardingCookies(getCookiesToDiscard: _*)
  }

  private def getCookiesToDiscard: Seq[DiscardingCookie] = {
    val cookieNames = Seq(SetupTradeDetailsCacheKey,
      traderDetailsCacheKey,
      businessChooseYourAddressCacheKey,
      vehicleLookupDetailsCacheKey,
      vehicleLookupResponseCodeCacheKey,
      vehicleLookupFormModelCacheKey,
      disposeFormModelCacheKey,
      disposeFormTransactionIdCacheKey,
      disposeFormTimestampIdCacheKey,
      disposeFormRegistrationNumberCacheKey,
      disposeModelCacheKey)
    cookieNames.map(cookieName => DiscardingCookie(name = CryptoHelper.encryptCookieName(cookieName)))
  }

  def submit = Action { implicit request =>
    val modelId = request.session.get("modelId")
    Logger.debug(s"BeforeYouStart - reading modelId from session: $modelId")
    Redirect(routes.SetUpTradeDetails.present())
  }
}

package controllers.disposal_of_vehicle

import play.api.mvc._
import play.api.Logger
import mappings.disposal_of_vehicle.Dispose._
import mappings.disposal_of_vehicle.VehicleLookup._
import mappings.disposal_of_vehicle.SetupTradeDetails._
import mappings.disposal_of_vehicle.TraderDetails._
import mappings.disposal_of_vehicle.BusinessChooseYourAddress._
import utils.helpers.CryptoHelper

class BeforeYouStart extends Controller {

  def present = Action { implicit request =>

    Ok(views.html.disposal_of_vehicle.before_you_start()).
      discardingCookies(getCookiesToDiscard: _*)
  }

  private def getCookiesToDiscard: Seq[DiscardingCookie] = {
    val cookieNames = Seq(SetupTradeDetailsCacheKey,
      traderDetailsCacheKey,
      businessChooseYourAddressCacheKey,
      vehicleLookupDetailsCacheKey,
      vehicleLookupResponseCodeCacheKey,
      vehicleLookupFormModelCacheKey,
      disposeFormModelCacheKey,
      disposeFormTransactionIdCacheKey,
      disposeFormTimestampIdCacheKey,
      disposeFormRegistrationNumberCacheKey,
      disposeModelCacheKey)
    cookieNames.map(cookieName => DiscardingCookie(name = CryptoHelper.encryptCookieName(cookieName)))
  }

  def submit = Action { implicit request =>
    val modelId = request.session.get("modelId")
    Logger.debug(s"BeforeYouStart - reading modelId from session: $modelId")
    Redirect(routes.SetUpTradeDetails.present())
  }
}

US137: Fix error reading existing cookies after withNewSession called

Former-commit-id: 51b2f5a3ac9d8a127b86c106ff2747c70eb44235


package providers

import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits._
import util.WithTiming._
import models.{LocationWithWeather, Location}

trait WeatherFetchStrategies {
  this: Providers =>

  def provider(name: String): Location => Future[LocationWithWeather] = { location =>
    providers(name).getLocationWithWeather(location) withTiming
  }

  val smhi: (Location) => Future[LocationWithWeather] = provider("smhi")

  val yr: (Location) => Future[LocationWithWeather] = provider("yr")

  val firstCompleted: Location => Future[LocationWithWeather] = { location =>
    val weatherF = providers.values.map(_.getLocationWithWeather(location) withTiming)
    Future.firstCompletedOf(weatherF)
  }

  val withRecovery: Location => Future[LocationWithWeather] = { location =>
    smhi(location).recoverWith {
       case _ => yr(location)
    }
  }

  val all: Location => Future[LocationWithWeather] = { location =>

    Future.sequence(
        providers.values
          .map(f => f.getLocationWithWeather(location) withTiming))
          .map(l => l.tail.fold[LocationWithWeather](l.head)(_ merge _)
      )
  }

}

package providers

import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits._
import util.WithTiming._
import models.{LocationWithWeather, Location}

trait WeatherFetchStrategies {
  this: Providers =>

  def provider(name: String): Location => Future[LocationWithWeather] = { location =>
    providers(name).getLocationWithWeather(location) withTiming
  }

  val smhi: (Location) => Future[LocationWithWeather] = provider("smhi")

  val yr: (Location) => Future[LocationWithWeather] = provider("yr")

  val firstCompleted: Location => Future[LocationWithWeather] = { location =>
    ??? //Todo add instructions
  }

  val withRecovery: Location => Future[LocationWithWeather] = { location =>
    ??? //Todo add instructions
  }

  val all: Location => Future[LocationWithWeather] = { location =>
    ??? //Todo add instructions
  }

}

Remove code for excersice 7

Remove code for excersice 7


package ingraph

import ingraph.testrunners.{IngraphTestRunner, Neo4jTestRunner}
import ingraph.tests.LdbcSnbTestCase

object BenchmarkMain {

  /**
    * args(0): number of runs
    * args(1): scale factor
    * args(2): query
    * args(3): tool
    * @param args
    */
  def main(args: Array[String]): Unit = {
    val runs = args(0).toInt
    val sf = args(1)
    val query = args(2).toInt
    val tool = args(3)

    val csvDir = s"../graphs/ldbc-snb-bi/csv-sf${sf}/"
    val dbDir = s"../graphs/ldbc-snb-bi/db-sf${sf}/graph.db"
    val tc = new LdbcSnbTestCase("bi", sf, query, csvDir)

    for (run <- 1 to runs) {
      tool.toLowerCase match {
        case "neo4j" =>
          val ntr = new Neo4jTestRunner(tc, Some(csvDir))
          val neo4jResults = ntr.run()
          ntr.close
        case "ingraph" =>
          val itr = new IngraphTestRunner(tc)
          val ingraphResults = itr.run()
          itr.close
      }
    }
  }

}

package ingraph

import ingraph.testrunners.{IngraphTestRunner, Neo4jTestRunner}
import ingraph.tests.LdbcSnbTestCase

object BenchmarkMain {

  /**
    * args(0): number of runs
    * args(1): scale factor
    * args(2): query
    * args(3): tool
    * @param args
    */
  def main(args: Array[String]): Unit = {
    val runs = args(0).toInt
    val sf = args(1)
    val query = args(2).toInt
    val tool = args(3)

    val csvDir = s"../graphs/ldbc-snb-bi/csv-sf${sf}/"
    val dbDir = s"../graphs/ldbc-snb-bi/db-sf${sf}/graph.db"
    val tc = new LdbcSnbTestCase("bi", sf, query, csvDir)

    for (run <- 1 to runs) {
      tool.toLowerCase match {
        case "neo4j" =>
          val ntr = new Neo4jTestRunner(tc, Some(dbDir))
          val neo4jResults = ntr.run()
          ntr.close
        case "ingraph" =>
          val itr = new IngraphTestRunner(tc)
          val ingraphResults = itr.run()
          itr.close
      }
    }
  }

}

Fix DB directory for benchmarking

Fix DB directory for benchmarking


import scala.util.Properties

import sbt._
import sbt.Keys._

object BuildSettings {
  val buildSettings = Defaults.defaultSettings ++ Seq(
    organization := "org.apache.spark",
    version := "0.1-SNAPSHOT",
    scalaVersion := "2.10.4",
    resolvers ++= Seq(
      Resolver.sonatypeRepo("snapshots"),
      Resolver.sonatypeRepo("releases"),
      Resolver.typesafeRepo("releases")
    ),
    parallelExecution in Test := false
  )
}

object SparkIntegrationTestsBuild extends Build {

  import BuildSettings._

  val SPARK_HOME = Properties.envOrNone("SPARK_HOME").getOrElse {
    throw new Exception("SPARK_HOME must be defined")
  }

  lazy val sparkCore = ProjectRef(
    file(SPARK_HOME),
    "core"
  )

  lazy val root = Project(
    "spark-integration-tests",
    file("."),
    settings = buildSettings ++ Seq(
      scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"),
      libraryDependencies ++= Seq(
        "org.scalatest" % "scalatest_2.10" % "2.2.1" % "test"
      )
    )
  ).dependsOn(sparkCore)
}

import scala.util.Properties

import sbt._
import sbt.Keys._

object BuildSettings {
  val buildSettings = Defaults.defaultSettings ++ Seq(
    organization := "org.apache.spark",
    version := "0.1-SNAPSHOT",
    scalaVersion := "2.10.4",
    resolvers ++= Seq(
      Resolver.sonatypeRepo("snapshots"),
      Resolver.sonatypeRepo("releases"),
      Resolver.typesafeRepo("releases")
    ),
    parallelExecution in Test := false
  )
}

object SparkIntegrationTestsBuild extends Build {

  import BuildSettings._

  val SPARK_HOME = Properties.envOrNone("SPARK_HOME").getOrElse {
    throw new Exception("SPARK_HOME must be defined")
  }

  lazy val sparkCore = ProjectRef(
    file(SPARK_HOME),
    "core"
  )

  lazy val sparkStreaming = ProjectRef(
    file(SPARK_HOME),
    "streaming"
  )

  lazy val streamingKafka = ProjectRef(
    file(SPARK_HOME),
    "streaming-kafka"
  )

  lazy val root = Project(
    "spark-integration-tests",
    file("."),
    settings = buildSettings ++ Seq(
      scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"),
      libraryDependencies ++= Seq(
        "org.scalatest" % "scalatest_2.10" % "2.2.1" % "test"
      )
    )
  ).dependsOn(sparkCore, sparkStreaming, streamingKafka)
}

Add Streaming deps. left out from last commit.


addSbtPlugin("io.gatling"         % "gatling-build-plugin"  % "5.0.0")
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.11.0")
addSbtPlugin("com.typesafe.sbt"   % "sbt-site"              % "1.4.1")
addSbtPlugin("org.wartremover"    % "sbt-wartremover"       % "3.0.5")
addSbtPlugin("ch.epfl.scala"      % "sbt-scalafix"          % "0.10.1")
addSbtPlugin("com.hanhuy.sbt"     % "kotlin-plugin"         % "2.0.0")
addSbtPlugin("net.moznion.sbt"    % "sbt-spotless"          % "0.1.3")

addSbtPlugin("io.gatling"         % "gatling-build-plugin"  % "5.0.0")
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.11.0")
addSbtPlugin("com.typesafe.sbt"   % "sbt-site"              % "1.4.1")
addSbtPlugin("org.wartremover"    % "sbt-wartremover"       % "3.0.6")
addSbtPlugin("ch.epfl.scala"      % "sbt-scalafix"          % "0.10.1")
addSbtPlugin("com.hanhuy.sbt"     % "kotlin-plugin"         % "2.0.0")
addSbtPlugin("net.moznion.sbt"    % "sbt-spotless"          % "0.1.3")

Update sbt-wartremover, wartremover to 3.0.6


addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.11")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")

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

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.11")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")

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


addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.13.1")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.18")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.25")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "0.6.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2")

addSbtCoursier

libraryDependencies ++= List(
  "com.thesamet.scalapb" %% "compilerplugin-shaded" % "0.8.0",
  "io.github.bonigarcia" % "webdrivermanager" % "3.0.0",
  "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
)

addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.13.1")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.18")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.25")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "0.6.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2")

addSbtCoursier

libraryDependencies ++= List(
  "com.thesamet.scalapb" %% "compilerplugin-shaded" % "0.8.4",
  "io.github.bonigarcia" % "webdrivermanager" % "3.0.0",
  "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
)

Update compilerplugin-shaded, ... to 0.8.4


package repositories.fileupload

import model.Exceptions.EventNotFoundException
import model.persisted.EventExamples
import model.persisted.eventschedules.{ EventType, SkillType, VenueType }
import play.api.libs.iteratee.{ Enumerator, Iteratee }
import repositories.CollectionNames
import testkit.MongoRepositorySpec

class FileUploadRepositorySpec extends MongoRepositorySpec {

  override val collectionName: String = CollectionNames.FILE_UPLOAD
  lazy val repository = repositories.fileUploadRepository

  private def storeAndRetrieveFile = {
    val testContent = "Test contents".toCharArray.map(_.toByte)
    val testContentType = "application/pdf"
    val id = repository.add(testContentType, testContent).futureValue
    val retrievedFile = repository.retrieve(id).futureValue
    retrievedFile.contentType mustBe testContentType
    retrievedFile.fileContents.run(Iteratee.consume[Array[Byte]]()).futureValue mustBe testContent
  }

  "add" must {
    "store a file with contentType" in {
      storeAndRetrieveFile
    }
  }

  "retrieve" must {
    "retrieve a file by id" in {
      storeAndRetrieveFile
    }
  }
}

package repositories.fileupload

import model.Exceptions.EventNotFoundException
import model.persisted.EventExamples
import model.persisted.eventschedules.{ EventType, SkillType, VenueType }
import play.api.libs.iteratee.{ Enumerator, Iteratee }
import repositories.CollectionNames
import testkit.MongoRepositorySpec

class FileUploadRepositorySpec extends MongoRepositorySpec {

  override val collectionName: String = CollectionNames.FILE_UPLOAD
  lazy val repository = repositories.fileUploadRepository

  "add" must {
    "store a file with contentType" in {
      val testContent = "Test contents".toCharArray.map(_.toByte)
      val testContentType = "application/pdf"
      val id = repository.add(testContentType, testContent).futureValue
      val retrievedFile = repository.retrieve(id).futureValue
      retrievedFile.contentType mustBe testContentType
      retrievedFile.fileContents.run(Iteratee.consume[Array[Byte]]()).futureValue mustBe testContent
    }
  }

  "retrieve" must {
    "retrieve a file by id" in {
      val testContent = "Test contents".toCharArray.map(_.toByte)
      val testContentType = "application/pdf"
      val id = repository.add(testContentType, testContent).futureValue
      val retrievedFile = repository.retrieve(id).futureValue
      retrievedFile.contentType mustBe testContentType
      retrievedFile.fileContents.run(Iteratee.consume[Array[Byte]]()).futureValue mustBe testContent
    }
  }
}

Remove DRY in fileupload tests

Remove DRY in fileupload tests


package pages

import uk.gov.dvla.vehicles.presentation.common.ConfigProperties.getProperty

package object acquire {
  private final val applicationContext = getProperty("application.context", default = "/")

  def buildAppUrl(urlPart: String) = {
    val appContextWithSlash = if (!applicationContext.endsWith("/")) s"/$applicationContext" else applicationContext
    val urlPartWithoutSlash = urlPart.dropWhile(_ == '/')

    appContextWithSlash + urlPartWithoutSlash
  }
}

package pages

import uk.gov.dvla.vehicles.presentation.common.ConfigProperties.getProperty

package object acquire {
  private final val applicationContext = getProperty("application.context", default = "/")

  def buildAppUrl(urlPart: String) = {
    val appContextWithSlash = if (!applicationContext.endsWith("/")) s"$applicationContext/" else applicationContext
    val urlPartWithoutSlash = urlPart.dropWhile(_ == '/')

    appContextWithSlash + urlPartWithoutSlash
  }
}

Add method to build app urls correctly

Add method to build app urls correctly


import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.76"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.5",
      "com.ning" % "async-http-client" % "1.9.39",
      "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")
  }
}

import com.github.retronym.SbtOneJar._

oneJarSettings

name := "api-build"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.77"

exportJars := true

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.5",
      "com.ning" % "async-http-client" % "1.9.39",
      "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.77


import play.PlayImport.PlayKeys._

name := "lib-play"

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

crossScalaVersions := Seq("2.11.8")

version := "0.2.16"

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.17"

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.17


lazy val root = (project in file(".")).settings(
  name := "scalatest",
  version := "200401",
  scalaVersion := "2.13.2",
  libraryDependencies ++= Seq(
    "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3"
  ),
  fork := false,
  packageName in Docker := "artima/scalatest-website",
  maintainer in Docker := "Artima Inc.",
  dockerExposedPorts ++= Seq(9000),
  dockerUpdateLatest := true
  //classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat  // Added in sbt 1.3 (https://www.scala-sbt.org/1.x/docs/sbt-1.3-Release-Notes.html), but still not working, so we fall back to sbt 1.2.
).enablePlugins(PlayScala, JavaServerAppPackaging, DockerPlugin)

lazy val root = (project in file(".")).settings(
  name := "scalatest-website",
  version := "200401",
  scalaVersion := "2.13.2",
  libraryDependencies ++= Seq(
    "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3"
  ),
  fork := false,
  packageName in Docker := "artima/scalatest-website",
  maintainer in Docker := "Artima Inc.",
  dockerExposedPorts ++= Seq(9000),
  dockerUpdateLatest := true
  //classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat  // Added in sbt 1.3 (https://www.scala-sbt.org/1.x/docs/sbt-1.3-Release-Notes.html), but still not working, so we fall back to sbt 1.2.
).enablePlugins(PlayScala, JavaServerAppPackaging, DockerPlugin)

Change name of sbt project from scalatest to scalatest-website.


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

organization := "io.flow"

scalaVersion in ThisBuild := "2.11.8"

version := "0.0.19"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.9",
      "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.20"

lazy val root = project
  .in(file("."))
  .settings(
    libraryDependencies ++= Seq(
      "com.typesafe.play" %% "play-json" % "2.5.9",
      "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.20


package core.loaders

import java.io.File

import core.controllers.AkkaRoute
import core.graphql.GraphQLSchema
import core.guice.injection.Injecting.injector
import net.codingwell.scalaguice.ScalaModule
import org.clapper.classutil.ClassFinder

object ModuleLoader {

  private val classLoader = getClass.getClassLoader
  private val classes = ClassFinder(List(".").map(new File(_))).getClasses()

  val guiceModules: List[ScalaModule] = instantiateClasses[ScalaModule](classOf[ScalaModule].getName)

  lazy val akkaRouteModules: List[AkkaRoute] = instantiateClassesWithInject[AkkaRoute](classOf[AkkaRoute].getName)
  lazy val graphQLSchemaModules: List[GraphQLSchema] = instantiateClassesWithInject[GraphQLSchema](classOf[GraphQLSchema].getName)

  private def instantiateClasses[T](classType: String) = {
    loadClasses(classType).map(_.newInstance.asInstanceOf[T])
  }

  private def instantiateClassesWithInject[T](classType: String) = {
    loadClasses(classType).map(injector.getInstance(_).asInstanceOf[T])
  }

  private def loadClasses(classType: String) = {
    classes.filter(_.implements(classType)).map(clazz => classLoader.loadClass(clazz.name)).toList
  }
}

package core.loaders

import java.io.File

import core.controllers.AkkaRoute
import core.graphql.GraphQLSchema
import core.guice.injection.Injecting.injector
import net.codingwell.scalaguice.ScalaModule
import org.clapper.classutil.ClassFinder
import util.Logger

object ModuleLoader extends Logger {

  private val classLoader = getClass.getClassLoader
  private val classes = ClassFinder(List(".").map(new File(_))).getClasses()
  private val ignoreModuleName = classOf[IgnoreModule].getSimpleName

  val guiceModules: List[ScalaModule] = instantiateClasses[ScalaModule](classOf[ScalaModule].getName)

  lazy val akkaRouteModules: List[AkkaRoute] = instantiateClassesWithInject[AkkaRoute](classOf[AkkaRoute].getName)
  lazy val graphQLSchemaModules: List[GraphQLSchema] = instantiateClassesWithInject[GraphQLSchema](classOf[GraphQLSchema].getName)

  private def instantiateClasses[T](classType: String) = {
    loadClasses(classType).map {
      clazz =>
        log.info(s"Instantiate a class: ${clazz.getName}")
        clazz.newInstance.asInstanceOf[T]
    }
  }

  private def instantiateClassesWithInject[T](classType: String) = {
    loadClasses(classType).map {
      clazz =>
        log.info(s"Instantiate a class with inject: ${clazz.getName}")
        injector.getInstance(clazz).asInstanceOf[T]
    }
  }

  private def loadClasses(classType: String) = {
    classes.filter {
      clazz => clazz.implements(classType) && !clazz.annotations.exists(_.descriptor.endsWith(ignoreModuleName + ";"))
    }.map(clazz => classLoader.loadClass(clazz.name)).toList
  }
}

Add checking of IgnoreModule annotation in loaded annotations


package controllers

import helpers.{UnitSpec, WithApplication}
import org.mockito.Mockito.when
import play.api.test.{FakeApplication, FakeRequest}
import play.api.test.Helpers._
import utils.helpers.Config

final class ApplicationUnitSpec extends UnitSpec {
  "index" should {

    "redirect the user to the start url" in new WithApplication {
      implicit val config = configWithStartUrl("/testStart")
      val result = new ApplicationRoot().index(FakeRequest())
      redirectLocation(result) should equal(Some("/testStart"))
    }

    "redirect the user to the start url when the start url does not have a starting slash" in new WithApplication {
      implicit val config = configWithStartUrl("testStart")
      val result = new ApplicationRoot().index(FakeRequest())
      redirectLocation(result) should equal(Some("/testStart"))
    }

    "redirect the user to the start url when there is an application context set " in
      new WithApplication(FakeApplication(additionalConfiguration = Map("application.context" -> "/testContext/"))) {
        implicit val config = configWithStartUrl("/testStart")
        val result = new ApplicationRoot().index(FakeRequest())
        redirectLocation(result) should equal(Some("/testContext/testStart"))
      }
  }

  private def configWithStartUrl(startUrl: String): Config = {
    val config = mock[Config]
    when(config.startUrl).thenReturn(startUrl)
    config
  }
}

package controllers

import helpers.{UnitSpec}
import org.mockito.Mockito.when
import play.api.test.{WithApplication, FakeApplication, FakeRequest}
import play.api.test.Helpers._
import utils.helpers.Config

final class ApplicationUnitSpec extends UnitSpec {
  "index" should {

    "redirect the user to the start url" in new WithApplication {
      implicit val config = configWithStartUrl("/testStart")
      val result = new ApplicationRoot().index(FakeRequest())
      redirectLocation(result) should equal(Some("/testStart"))
    }

    "redirect the user to the start url when the start url does not have a starting slash" in new WithApplication {
      implicit val config = configWithStartUrl("testStart")
      val result = new ApplicationRoot().index(FakeRequest())
      redirectLocation(result) should equal(Some("/testStart"))
    }

    "redirect the user to the start url when there is an application context set " in
      new WithApplication(app = FakeApplication(additionalConfiguration = Map("application.context" -> "/testContext/"))) {
        implicit val config = configWithStartUrl("/testStart")
        val result = new ApplicationRoot().index(FakeRequest())
        redirectLocation(result) should equal(Some("/testContext/testStart"))
      }
  }

  private def configWithStartUrl(startUrl: String): Config = {
    val config = mock[Config]
    when(config.startUrl).thenReturn(startUrl)
    config
  }
}

Fix subtle bug which fails tests dependant the order they are executed, due to some global state