package org.embulk.input.dynamodb.operation

import com.amazonaws.services.dynamodbv2.model.QueryRequest
import org.embulk.config.{Config, ConfigDefault}

import scala.util.chaining._

object DynamodbQueryOperation {

  trait Task extends DynamodbOperationCommonOptions.Task {

    // ref. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions
    @Config("key_condition_expression")
    def getKeyConditionExpression: String

    // TODO: Is it needed in the embulk context?
    // ref. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions
    @Config("scan_index_forward")
    @ConfigDefault("true")
    def getScanIndexForward: Boolean

  }
}

case class DynamodbQueryOperation(task: DynamodbQueryOperation.Task) {

  def newRequest: QueryRequest = {
    new QueryRequest()
      .tap(r => DynamodbOperationCommonOptions.configureRequest(r, task))
      .tap(r => r.setKeyConditionExpression(task.getKeyConditionExpression))
      .tap(r => r.setScanIndexForward(task.getScanIndexForward))
  }

  def getEmbulkTaskCount: Int = 1
}

package org.embulk.input.dynamodb.operation

import com.amazonaws.services.dynamodbv2.model.QueryRequest
import org.embulk.config.{Config, ConfigDefault}

import scala.util.chaining._

object DynamodbQueryOperation {

  trait Task extends AbstractDynamodbOperation.Task {

    // ref. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions
    @Config("key_condition_expression")
    def getKeyConditionExpression: String

    // TODO: Is it needed in the embulk context?
    // ref. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions
    @Config("scan_index_forward")
    @ConfigDefault("true")
    def getScanIndexForward: Boolean

  }
}

case class DynamodbQueryOperation(task: DynamodbQueryOperation.Task)
    extends AbstractDynamodbOperation[QueryRequest](task) {

  def newRequest: QueryRequest = {
    new QueryRequest()
      .tap(configureRequest)
      .tap(r => r.setKeyConditionExpression(task.getKeyConditionExpression))
      .tap(r => r.setScanIndexForward(task.getScanIndexForward))
  }

}

Revert "Delete AbstractDynamodbOperation, use DynamodbOperationCommonOptions instead."

This reverts commit 3c6821bf


package hmda.model.filing.lar.enums

sealed trait PayableToInstitutionEnum extends LarEnum

object PayableToInstitutionEnum extends LarCodeEnum[PayableToInstitutionEnum] {
  override val values = List(1, 2, 3)

  override def valueOf(code: Int): PayableToInstitutionEnum = {
    code match {
      case 1 => NotInitiallyPayableToInstitution
      case 2 => NotInitiallyPayableToInstitution
      case 3 => PayableToInstitutionNotApplicable
      case _ => InvalidPayableToInstitutionCode
    }
  }
}

case object InititallyPayableToInstitution extends PayableToInstitutionEnum {
  override val code: Int = 1
  override val description: String = "Inititally payable to your institution"
}

case object NotInitiallyPayableToInstitution extends PayableToInstitutionEnum {
  override val code: Int = 2
  override val description: String = "Not initially payable to your institution"
}

case object PayableToInstitutionNotApplicable extends PayableToInstitutionEnum {
  override val code: Int = 3
  override val description: String = "Not applicable"
}

case object InvalidPayableToInstitutionCode extends PayableToInstitutionEnum {
  override def code: Int = -1
  override def description: String = "Invalid Code"
}

package hmda.model.filing.lar.enums

sealed trait PayableToInstitutionEnum extends LarEnum

object PayableToInstitutionEnum extends LarCodeEnum[PayableToInstitutionEnum] {
  override val values = List(1, 2, 3)

  override def valueOf(code: Int): PayableToInstitutionEnum = {
    code match {
      case 1 => InititallyPayableToInstitution
      case 2 => NotInitiallyPayableToInstitution
      case 3 => PayableToInstitutionNotApplicable
      case _ => InvalidPayableToInstitutionCode
    }
  }
}

case object InititallyPayableToInstitution extends PayableToInstitutionEnum {
  override val code: Int = 1
  override val description: String = "Inititally payable to your institution"
}

case object NotInitiallyPayableToInstitution extends PayableToInstitutionEnum {
  override val code: Int = 2
  override val description: String = "Not initially payable to your institution"
}

case object PayableToInstitutionNotApplicable extends PayableToInstitutionEnum {
  override val code: Int = 3
  override val description: String = "Not applicable"
}

case object InvalidPayableToInstitutionCode extends PayableToInstitutionEnum {
  override def code: Int = -1
  override def description: String = "Invalid Code"
}

Fix payable to institution enum match

Fix payable to institution enum match


package eu.timepit.refined.scalaz

import eu.timepit.refined.TestUtils._
import eu.timepit.refined.api.{ RefType, RefTypeSpec }
import eu.timepit.refined.numeric._
import eu.timepit.refined.scalaz.auto._
import org.scalacheck.Prop._
import shapeless.test.illTyped

import _root_.scalaz.@@

class RefTypeSpecScalazTag extends RefTypeSpec[@@]("scalaz.@@") {

  property("refineM with type alias") = secure {
    type PositiveInt = Int @@ Positive

    val x: PositiveInt = RefType[@@].refineM(5)
    val y: PositiveInt = 5
    val z = 5: PositiveInt
    illTyped("val a: PositiveInt = -5", "Predicate failed: \\(-5 > 0\\).*")
    x == y && y == z
  }

  property("(T @@ P) <!: T") = wellTyped {
    illTyped("implicitly[(Int @@ Positive) <:< Int]", "Cannot prove.*")
  }
}

package eu.timepit.refined.scalaz

import _root_.scalaz.@@
import eu.timepit.refined.TestUtils._
import eu.timepit.refined.api.{ RefType, RefTypeSpec }
import eu.timepit.refined.numeric._
import eu.timepit.refined.scalaz.auto._
import org.scalacheck.Prop._
import shapeless.test.illTyped

class RefTypeSpecScalazTag extends RefTypeSpec[@@]("scalaz.@@") {

  property("refineM with type alias") = secure {
    type PositiveInt = Int @@ Positive

    val x: PositiveInt = RefType[@@].refineM(5)
    val y: PositiveInt = 5
    val z = 5: PositiveInt
    illTyped("val a: PositiveInt = -5", "Predicate failed: \\(-5 > 0\\).*")
    x == y && y == z
  }

  property("(T @@ P) <!: T") = wellTyped {
    illTyped("implicitly[(Int @@ Positive) <:< Int]", "Cannot prove.*")
  }
}

Fix import order in test

Fix import order in test


/**
 * Copyright (C) 2010-2012 LShift Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.lshift.diffa.kernel.config.limits

import net.lshift.diffa.kernel.config.ServiceLimit

object ResponseSizeLimit extends ServiceLimit {
  def key = "scan.response.size"
  def description = "The maximum size (in bytes) of the response for a single scan request"
  def defaultLimit = 40
  def hardLimit = 50
}

/**
 * Copyright (C) 2010-2012 LShift Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.lshift.diffa.kernel.config.limits

import net.lshift.diffa.kernel.config.ServiceLimit

object ResponseSizeLimit extends ServiceLimit {
  def key = "scan.response.size"
  def description = "The maximum size (in bytes) of the response for a single scan request"
  def defaultLimit = 2 * 1024 * 1024
  def hardLimit = 10 * 1024 * 1024
}

Set a sensible default response size limit.


package com.twitter.finagle

import java.util.concurrent.Executors
import com.twitter.concurrent.NamedPoolThreadFactory

/**
 * Package netty3 implements the bottom finagle primitives:
 * {{com.twitter.finagle.Server}} and a client transport in terms of
 * the netty3 event loop.
 *
 * Note: when {{com.twitter.finagle.builder.ClientBuilder}} and
 * {{com.twitter.finagle.builder.ServerBuilder}} are deprecated,
 * package netty3 can move into its own package, so that only the
 * (new-style) clients and servers that depend on netty3 bring it in.
 */
package object netty3 {
  val Executor = Executors.newCachedThreadPool(
    new NamedPoolThreadFactory("finagle/netty3", true/*daemon*/))

  object param {
    /**
     * A class eligible for configuring a netty3 timer.
     */
    case class Netty3Timer(timer: org.jboss.netty.util.Timer)
    implicit object netty3Timer extends Stack.Param[Netty3Timer] {
      val default = Netty3Timer(util.DefaultTimer)
    }
  }
}

package com.twitter.finagle

import java.util.concurrent.Executors
import com.twitter.concurrent.NamedPoolThreadFactory

/**
 * Package netty3 implements the bottom finagle primitives:
 * {{com.twitter.finagle.Server}} and a client transport in terms of
 * the netty3 event loop.
 *
 * Note: when {{com.twitter.finagle.builder.ClientBuilder}} and
 * {{com.twitter.finagle.builder.ServerBuilder}} are deprecated,
 * package netty3 can move into its own package, so that only the
 * (new-style) clients and servers that depend on netty3 bring it in.
 */
package object netty3 {
  val Executor = Executors.newCachedThreadPool(
    new NamedPoolThreadFactory("finagle/netty3", true/*daemon*/))

  object param {
    /**
     * A class eligible for configuring a netty3 timer.
     */
    case class Netty3Timer(timer: org.jboss.netty.util.Timer)
    implicit object Netty3Timer extends Stack.Param[Netty3Timer] {
      val default = Netty3Timer(util.DefaultTimer)
    }
  }
}

[split] finagle-core: Fix a Netty3Timer capitalization bug Problem Some projects get NoClassDef found error when run with pants.  This is concerning because they compiled successfully, even with all of the right dependencies (building off of master).

Solution
Renamed netty3Timer to Netty3Timer (a typo)

Result
We no longer get the NoClassDef error.

RB_ID=330261
NO-QUEUE=true


package scala.tools.eclipse
package diagnostic

import org.eclipse.jface.action.IAction
import org.eclipse.jface.viewers.{ ISelection, IStructuredSelection }
import org.eclipse.ui.{ IObjectActionDelegate, IWorkbenchPart, IWorkbenchWindowActionDelegate, IWorkbenchWindow }

import scala.tools.eclipse.ScalaPlugin.plugin
import scala.tools.eclipse.javaelements.JDTUtils

class RunDiagnosticAction extends IObjectActionDelegate with IWorkbenchWindowActionDelegate {
  private var parentWindow: IWorkbenchWindow = null

  override def init(window: IWorkbenchWindow) {
    parentWindow = window
  }

  def dispose = { }

	def selectionChanged(action: IAction, selection: ISelection) {  }

  def run(action: IAction) {
    plugin check {
      new DiagnosticDialog(parentWindow.getShell).open
    }
  }

  def setActivePart(action: IAction, targetPart: IWorkbenchPart) { }
}

package scala.tools.eclipse
package diagnostic

import org.eclipse.jface.action.IAction
import org.eclipse.jface.viewers.{ ISelection, IStructuredSelection }
import org.eclipse.ui.{ IObjectActionDelegate, IWorkbenchPart, IWorkbenchWindowActionDelegate, IWorkbenchWindow }

import scala.tools.eclipse.ScalaPlugin.plugin
import scala.tools.eclipse.javaelements.JDTUtils

class RunDiagnosticAction extends IObjectActionDelegate with IWorkbenchWindowActionDelegate {
  private var parentWindow: IWorkbenchWindow = null

  override def init(window: IWorkbenchWindow) {
    parentWindow = window
  }

  def dispose = { }

	def selectionChanged(action: IAction, selection: ISelection) {  }

  def run(action: IAction) {
    plugin check {
      val shell = if (parentWindow == null) ScalaPlugin.getShell else parentWindow.getShell
      new DiagnosticDialog(shell).open
    }
  }

  def setActivePart(action: IAction, targetPart: IWorkbenchPart) { }
}

Fix NPE when selecting "Run Scala Diagnostics" from context menu.


package uk.ac.cdrc.mintsearch.neo4j

import org.scalatest._
import org.neo4j.driver.v1._
import org.neo4j.harness.TestServerBuilders

/**
 * Created by ucfawli on 29-Nov-16.
 */
class TestFullTextIndexSpec extends FlatSpec {

  def neo4jServer = TestServerBuilders.newInProcessBuilder().withProcedure(classOf[FullTextIndex]).newServer()

  "A test" should "run" in {
    val driver: Driver = GraphDatabase.driver(neo4jServer.boltURI(), Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig())
    // Given I've started Neo4j with the FullTextIndex procedure class
    //       which my 'neo4j' rule above does.
    val session = driver.session()

    // And given I have a node in the database
    val nodeId: Long = session.run("CREATE (p:User {name:'Brookreson'}) RETURN id(p)")
      .single()
      .get(0).asLong()

    // When I use the index procedure to index a node
    session.run(s"CALL mint.fulltext_index($nodeId, ['name'])")

    // Then I can search for that node with lucene query syntax
    val result = session.run("CALL mint.fulltext_search('User', 'name:Brook*')")
    assert(result.single().get("nodeId").asLong() === nodeId)
  }

}

package uk.ac.cdrc.mintsearch.neo4j

import org.scalatest._
import org.neo4j.driver.v1._
import org.neo4j.harness.TestServerBuilders

/**
 * Created by ucfawli on 29-Nov-16.
 */
class TestFullTextIndexSpec extends FlatSpec {

  trait Neo4JFixture {
    private val _builder = TestServerBuilders.newInProcessBuilder()
    def builder = _builder
    lazy val neo4jServer = builder.newServer()
  }

  trait Neo4JFixtureFullTextSearchProcedure extends Neo4JFixture {
    override val builder = super.builder.withProcedure(classOf[FullTextIndex])
  }

  "A test" should "run" in new Neo4JFixtureFullTextSearchProcedure {
    val driver: Driver = GraphDatabase.driver(neo4jServer.boltURI(), Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig)
    // Given I've started Neo4j with the FullTextIndex procedure class
    //       which my 'neo4j' rule above does.
    val session = driver.session()

    // And given I have a node in the database
    val nodeId: Long = session.run("CREATE (p:User {name:'Brookreson'}) RETURN id(p)")
      .single()
      .get(0).asLong()

    // When I use the index procedure to index a node
    session.run(s"CALL mint.fulltext_index($nodeId, ['name'])")

    // Then I can search for that node with lucene query syntax
    val result = session.run("CALL mint.fulltext_search('User', 'name:Brook*')")
    assert(result.single().get("nodeId").asLong() === nodeId)
  }

}

Use fixtures for testing procedures

Use fixtures for testing procedures


package ciris.cats.effect.api

import ciris.PropertySpec
import ciris.api.Sync

final class CatsEffectInstancesForCirisSpec extends PropertySpec {
  "CatsEffectInstancesForCiris" when {
    "providing instances for IO" should {
      "be able to provide all required instances" in {
        import _root_.cats.effect.IO
        import ciris.cats.effect._

        val s = Sync[IO]
        s.suspend(IO(1)).unsafeRunSync() shouldBe 1
        s.flatMap(IO(1))(_ => IO(2)).unsafeRunSync() shouldBe 2
        s.raiseError(new Error("message")).attempt.unsafeRunSync() shouldBe a[Left[_, _]]
        s.handleErrorWith(IO.raiseError(new Error("message")))(_ => IO(1)).unsafeRunSync() shouldBe 1
        s.pure(1).unsafeRunSync() shouldBe 1
        s.product(IO(1), IO(2)).unsafeRunSync() shouldBe ((1, 2))
        s.map(IO(1))(a => 2 + a).unsafeRunSync() shouldBe 3
      }
    }
  }
}

package ciris.cats.effect.api

import ciris.PropertySpec
import ciris.api.Sync

final class CatsEffectInstancesForCirisSpec extends PropertySpec {
  "CatsEffectInstancesForCiris" when {
    "providing instances for IO" should {
      "be able to provide all required instances" in {
        import _root_.cats.effect.IO
        import ciris.cats.effect._

        val s = Sync[IO]
        s.suspend(IO(1)).unsafeRunSync() shouldBe 1
        s.flatMap(IO(1))(_ => IO(2)).unsafeRunSync() shouldBe 2
        s.raiseError(new Error("message")).attempt.unsafeRunSync() shouldBe a[Left[_, _]]
        s.handleErrorWith(IO.raiseError(new Error("message")))(_ => IO(1)).unsafeRunSync() shouldBe 1
        s.pure(1).unsafeRunSync() shouldBe 1
        s.product(IO(1), IO(2)).unsafeRunSync() shouldBe ((1, 2))
        s.map(IO(1))(a => 2 + a).unsafeRunSync() shouldBe 3
      }

      "be able to use it together with ciris-cats" in {
        import ciris._
        import ciris.cats._
        import ciris.cats.effect._
        import _root_.cats.effect.IO

        case class TestConfig(env: String, prop: String)

        val config =
          loadConfig(
            envF[IO, String]("TEST"),
            propF[IO, String]("file.encoding")
          )(TestConfig)
      }
    }
  }
}

Add cats and cats-effect compatibility test


package io.vamp.workflow_driver

import akka.actor.{ActorRef, ActorSystem}
import akka.util.Timeout
import com.typesafe.scalalogging.LazyLogging
import io.vamp.common.{ClassProvider, Config, Namespace}
import io.vamp.common.akka.{ActorBootstrap, IoC}
import io.vamp.workflow_driver.notification.{UnsupportedWorkflowDriverError, WorkflowDriverNotificationProvider}

import scala.concurrent.{ExecutionContext, Future}

class WorkflowDriverBootstrap extends ActorBootstrap with WorkflowDriverNotificationProvider with LazyLogging {

  def createActors(implicit actorSystem: ActorSystem, namespace: Namespace, timeout: Timeout) = {
    implicit val ec: ExecutionContext = actorSystem.dispatcher
    val types = Config.string("vamp.workflow-driver.type")().toLowerCase.split(',').map(_.trim).toList

    val drivers: Future[List[ActorRef]] = Future.sequence(types.map { name ⇒
      ClassProvider.find[WorkflowDriver](name) match {
        case Some(clazz) ⇒ IoC.createActor(clazz)
        case None        ⇒ {
          logger.info(s"UnsupportedWorkflowDriverError : ${name}")
          throwException(UnsupportedWorkflowDriverError(name))
        }
      }
    })

    types.foreach { t ⇒ info(s"Workflow driver: $t") }
    drivers.flatMap(IoC.createActor[WorkflowDriverActor](_)).map(_ :: Nil)
  }
}

package io.vamp.workflow_driver

import akka.actor.{ ActorRef, ActorSystem }
import akka.util.Timeout
import io.vamp.common.{ ClassProvider, Config, Namespace }
import io.vamp.common.akka.{ ActorBootstrap, IoC }
import io.vamp.workflow_driver.notification.{ UnsupportedWorkflowDriverError, WorkflowDriverNotificationProvider }

import scala.concurrent.{ ExecutionContext, Future }

class WorkflowDriverBootstrap extends ActorBootstrap with WorkflowDriverNotificationProvider {

  def createActors(implicit actorSystem: ActorSystem, namespace: Namespace, timeout: Timeout) = {
    implicit val ec: ExecutionContext = actorSystem.dispatcher
    val types = Config.string("vamp.workflow-driver.type")().toLowerCase.split(',').map(_.trim).toList

    val drivers: Future[List[ActorRef]] = Future.sequence(types.map { name ⇒
      ClassProvider.find[WorkflowDriver](name) match {
        case Some(clazz) ⇒ {
          logger.info(s"WorkflowDriver created fro driver : ${name}")
          IoC.createActor(clazz)
        }
        case None ⇒ {
          logger.info(s"UnsupportedWorkflowDriverError : ${name}")
          throwException(UnsupportedWorkflowDriverError(name))
        }
      }
    })

    types.foreach { t ⇒ info(s"Workflow driver: $t") }
    drivers.flatMap(IoC.createActor[WorkflowDriverActor](_)).map(_ :: Nil)
  }
}

Add log to Workflow Driver Bootstrap

Add log to Workflow Driver Bootstrap


package io.reactors
package protocol

trait ServerProtocols {
  /** A server channel accepts tuples with the request event and channel to reply on.
   */
  type Server[T, S] = Channel[(T, Channel[S])]

  implicit class ServerSystemOps(val system: ReactorSystem) {
    /** Open a new server channel.
     */
    def server[T, S](name: String = ""): Connector[(T, Channel[S])] =
      system.channels.named(name).open[(T, Channel[S])]
  }

  implicit class ServerChannelOps[T, @specialized(Int, Long, Double) S: Arrayable](
    val server: Server[T, S]
  ) {
    /** Request a single reply from the server channel.
     *
     *  Returns an `IVar` with the server response.
     *  If the server responds with multiple events, only the first event is returned.
     *
     *  @param x     request event
     *  @return      the single assignment variable with the reply
     */
    def ?(x: T): IVar[S] = {
      val connector = Reactor.self.system.channels.open[S]
      val result = connector.events.toIVar
      result.onDone(connector.seal())
      server ! ((x, connector.channel))
      result
    }
  }
}

package io.reactors
package protocol

trait ServerProtocols {
  /** A server channel accepts tuples with the request event and channel to reply on.
   */
  type Server[T, S] = Channel[(T, Channel[S])]

  implicit class ServerSystemOps(val system: ReactorSystem) {
    /** Open a new server channel.
     */
    def server[T, S](name: String = ""): Connector[(T, Channel[S])] =
      system.channels.named(name).open[(T, Channel[S])]
  }

  implicit class ServerChannelOps[T, @specialized(Int, Long, Double) S: Arrayable](
    val server: Server[T, S]
  ) {
    /** Request a single reply from the server channel.
     *
     *  Returns an `IVar` with the server response.
     *  If the server responds with multiple events, only the first event is returned.
     *
     *  @param x     request event
     *  @return      the single assignment variable with the reply
     */
    def ?(x: T): IVar[S] = {
      val connector = Reactor.self.system.channels.open[S]
      val result = connector.events.toIVar
      result.onDone(connector.seal())
      server ! ((x, connector.channel))
      result
    }

    /** Request a stream of replies from the server channel.
     *
     *  Server can reply with multiple events.
     *
     *  @param x     request event
     *  @return      an event stream with the server replies
     */
    def stream(x: T): Events[S] = {
      ???
    }
  }
}

Add stub for `stream` to server protocols.


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.21.24",
  "org.http4s" %% "http4s-circe" % "0.21.24",
)

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.0",
  "org.http4s" %% "http4s-circe" % "0.22.0",
)

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


package com.example

trait PluginModule {
  //def init
}

package persister {
  trait Storage {
    def read: String
  }

  trait StorageModule extends PluginModule {
    def storage: Storage
  }
}

package authentication {
  class Authentication(storage: persister.Storage) {
    def login = storage.read
  }

  trait AuthenticationModule extends PluginModule {
    lazy val authentication = new Authentication(storage)
    def storage: persister.Storage
  }
}

package persister {
  trait DatabaseModule extends persister.StorageModule {
    class Database() extends persister.Storage {
      def read = "Read from database"
    }

    lazy val storage = new Database
  }
}

package persister {
  trait MemStorageModule extends persister.StorageModule {
    class MemStorage() extends persister.Storage {
      def read = "Read from memory"
    }

    lazy val storage = new MemStorage
  }
}

object DI extends App {
  val databaseModules = new authentication.AuthenticationModule
    with persister.DatabaseModule

  val memoryModules = new authentication.AuthenticationModule
    with persister.MemStorageModule

  println(memoryModules.authentication.login)
  println(databaseModules.authentication.login)
}

package com.example

trait PluginModule {
  def init: Unit = {}
}

package persister {
  trait Storage {
    def read: String
  }

  trait StorageModule extends PluginModule {
    def storage: Storage
  }
}

package authentication {
  class Authentication(storage: persister.Storage) {
    def login = storage.read
  }

  trait AuthenticationModule extends PluginModule {
    override def init = {
      super.init
      println("AuthenticationModule")
    }

    lazy val authentication = new Authentication(storage)
    def storage: persister.Storage
  }
}

package persister {
  class Database() extends persister.Storage {
    def read = "Read from database"
  }

  trait DatabaseModule extends persister.StorageModule {
    override def init = {
      super.init
      println("DatabaseModule")
    }

    lazy val storage = new Database
  }
}

package persister {
  class MemStorage() extends persister.Storage {
    def read = "Read from memory"
  }

  trait MemStorageModule extends persister.StorageModule {
    override def init = {
      super.init
      println("MemStorageModule")
    }

    lazy val storage = new MemStorage
  }
}

object DI extends App {
  val databaseModules = new authentication.AuthenticationModule
    with persister.DatabaseModule

  val memoryModules = new authentication.AuthenticationModule
    with persister.MemStorageModule

  memoryModules.init
  databaseModules.init

  println(memoryModules.authentication.login)
  println(databaseModules.authentication.login)
}

Add init method for Modules

Add init method for Modules


package gd.eval
import gd.eval.languages._

object Router {
  def route(language: String, code: String) = language match {
    case "ruby" | "mri" => Ruby(code)
    case "scala" => Scala(code)
    case "c" => C(code)
  }
}

package gd.eval
import gd.eval.languages._

object Router {
  def route(language: String, code: String) = language match {
    case "ruby" | "mri" => Some(Ruby(code))
    case "scala" => Some(Scala(code))
    case "c" => Some(C(code))
    case _ => None
  }
}

Make Router.route return an Option[SandboxedLanguage], and None if we hit an unimplemented language.


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.2",
  "org.http4s" %% "http4s-ember-client" % "0.23.15",
  "org.http4s" %% "http4s-circe" % "0.23.15",
)

// native packager and scoverage are conflicting...
libraryDependencySchemes ++= Seq(
  "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)

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.3",
  "org.http4s" %% "http4s-ember-client" % "0.23.15",
  "org.http4s" %% "http4s-circe" % "0.23.15",
)

// native packager and scoverage are conflicting...
libraryDependencySchemes ++= Seq(
  "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)

Update circe-core, circe-generic, ... to 0.14.3 in series/0.23


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.13.0",
  "org.http4s" %% "http4s-blaze-client" % "0.21.5",
  "org.http4s" %% "http4s-circe" % "0.21.5",
)

// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.3.20"

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.13.0",
  "org.http4s" %% "http4s-blaze-client" % "0.21.7",
  "org.http4s" %% "http4s-circe" % "0.21.7",
)

// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.3.20"

Update http4s-blaze-client, http4s-circe to 0.21.7


package uk.ac.wellcome.messaging.test.fixtures

import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.cloudwatch.{
  AmazonCloudWatch,
  AmazonCloudWatchClientBuilder
}
import uk.ac.wellcome.test.fixtures.ImplicitLogging

import scala.concurrent.duration._

trait CloudWatch extends ImplicitLogging {
  protected val awsNamespace: String = "test"
  protected val flushInterval: FiniteDuration = 1 second

  protected val localCloudWatchEndpointUrl = "http://localhost:4582"
  protected val regionName = "eu-west-1"

  protected val accessKey: String = "accessKey1"
  protected val secretKey: String = "verySecretKey1"

  def cloudWatchLocalFlags =
    Map(
      "aws.cloudWatch.endpoint" -> localCloudWatchEndpointUrl
    )

  private val credentials = new AWSStaticCredentialsProvider(
    new BasicAWSCredentials(accessKey, secretKey))

  val cloudWatchClient: AmazonCloudWatch = AmazonCloudWatchClientBuilder
    .standard()
    .withCredentials(credentials)
    .withEndpointConfiguration(
      new EndpointConfiguration(localCloudWatchEndpointUrl, regionName))
    .build()
}

package uk.ac.wellcome.messaging.test.fixtures

import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.cloudwatch.{
  AmazonCloudWatch,
  AmazonCloudWatchClientBuilder
}
import uk.ac.wellcome.test.fixtures.ImplicitLogging

import scala.concurrent.duration._

trait CloudWatch extends ImplicitLogging {
  protected val awsNamespace: String = "test"

  protected val localCloudWatchEndpointUrl: String = "http://localhost:4582"
  protected val regionName: String = "eu-west-1"

  protected val flushInterval: FiniteDuration = 1 second

  protected val accessKey: String = "accessKey1"
  protected val secretKey: String = "verySecretKey1"

  def cloudWatchLocalFlags =
    Map(
      "aws.cloudWatch.endpoint" -> localCloudWatchEndpointUrl
    )

  private val credentials = new AWSStaticCredentialsProvider(
    new BasicAWSCredentials(accessKey, secretKey))

  val cloudWatchClient: AmazonCloudWatch = AmazonCloudWatchClientBuilder
    .standard()
    .withCredentials(credentials)
    .withEndpointConfiguration(
      new EndpointConfiguration(localCloudWatchEndpointUrl, regionName))
    .build()

}

Reduce diff churn in GitHub

Reduce diff churn in GitHub


/* Copyright 2009-2018 EPFL, Lausanne */

package stainless.lang
import stainless.annotation._

@ignore
class Real {

   def +(a: Real): Real = ???
   def -(a: Real): Real = ???
   def *(a: Real): Real = ???
   def /(a: Real): Real = ???

   def unary_- : Real = ???

   def > (a: Real): Boolean = ???
   def >=(a: Real): Boolean = ???
   def < (a: Real): Boolean = ???
   def <=(a: Real): Boolean = ???

}

@ignore
object Real {
  def apply(n: BigInt, d: BigInt): Real = ???
  def apply(n: BigInt): Real = ???
}

/* Copyright 2009-2018 EPFL, Lausanne */

package stainless.lang
import stainless.annotation._

@ignore
class Real(val theReal: scala.math.BigDecimal) {

   def +(a: Real): Real = new Real(theReal + a.theReal)
   def -(a: Real): Real = new Real(theReal - a.theReal)
   def *(a: Real): Real = new Real(theReal * a.theReal)
   def /(a: Real): Real = new Real(theReal / a.theReal)

   def unary_- : Real = new Real(- theReal)

   def > (a: Real): Boolean = theReal >  a.theReal
   def >=(a: Real): Boolean = theReal >= a.theReal
   def < (a: Real): Boolean = theReal <  a.theReal
   def <=(a: Real): Boolean = theReal <= a.theReal

}

@ignore
object Real {
  def apply(n: BigInt, d: BigInt): Real = new Real(scala.math.BigDecimal(n) / scala.math.BigDecimal(d))
  def apply(n: BigInt): Real = new Real(scala.math.BigDecimal(n))
}

Add underlying operations for library reals


import scalariform.formatter.preferences._
import com.typesafe.sbt.SbtScalariform.ScalariformKeys

sbtPlugin := true

name := "openmole-buildsystem-plugin"

organization := "org.openmole"

//resolvers += Classpaths.sbtPluginSnapshots

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

libraryDependencies ++= Seq(
  "com.jsuereth" %% "scala-arm" % "2.0",
  "org.apache.commons" % "commons-compress" % "1.10",
  "org.json4s" %% "json4s-native" % "3.5.3")

import scalariform.formatter.preferences._
import com.typesafe.sbt.SbtScalariform.ScalariformKeys

sbtPlugin := true

name := "openmole-buildsystem-plugin"

organization := "org.openmole"

//resolvers += Classpaths.sbtPluginSnapshots

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

libraryDependencies ++= Seq(
  "com.jsuereth" %% "scala-arm" % "2.0",
  "org.apache.commons" % "commons-compress" % "1.10",
  "org.json4s" %% "json4s-native" % "3.5.3")

Revert "[Build] update sbt osgi"

Revert "[Build] update sbt osgi"

This reverts commit f9d9b69fcdf5139995694b9dc15b3ffd96fffd3c.


package com.azavea.rf.database.fields

import com.azavea.rf.database.ExtendedPostgresDriver.api._
import com.azavea.rf.database.query.UserQueryParameters
import com.azavea.rf.database.tables.Users
import com.azavea.rf.datamodel.{User, Visibility}
import slick.lifted.ForeignKeyQuery

trait UserFkVisibleFields extends UserFkFields with VisibilityField { self: Table[_] => }

object UserFkVisibleFields {
  implicit class DefaultQuery[M <: UserFkVisibleFields, U, C[_]](that: Query[M, U, Seq]) {
    def filterUserVisibility(user: User) = {
      that.filter { rec => {
        rec.visibility === Visibility.fromString("PUBLIC") || rec.createdBy === user.id
      }
      }
    }
  }
}

package com.azavea.rf.database.fields

import com.azavea.rf.database.ExtendedPostgresDriver.api._
import com.azavea.rf.database.query.UserQueryParameters
import com.azavea.rf.database.tables.Users
import com.azavea.rf.datamodel.{User, Visibility}
import slick.lifted.ForeignKeyQuery

trait UserFkVisibleFields extends UserFkFields with VisibilityField { self: Table[_] => }

object UserFkVisibleFields {
  implicit class DefaultQuery[M <: UserFkVisibleFields, U, C[_]](that: Query[M, U, Seq]) {
    def filterUserVisibility(user: User) = {
      that.filter { rec => {
        rec.visibility === Visibility.fromString("PUBLIC") || rec.createdBy === user.id ||  user.isInRootOrganization
      }
      }
    }
  }
}

Allow root org override for user visibility filters

This relaxes the restriction of visibility of objects to allow root
users to see objects from all organizations.


/*
 Copyright 2013 Twitter, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

package com.twitter.summingbird.scalding.service

import com.twitter.summingbird.scalding._

object EmptyService extends Service[Any, Any] {
  def lookup[W](getKeys: PipeFactory[(Any, W)]): PipeFactory[(Any, (W, Option[Any]))] =
    getKeys.map { _.map { _.map { case (t, (k, v)) => (t, (k, (v, None: Option[Any]))) } } }
}

/*
 Copyright 2013 Twitter, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

package com.twitter.summingbird.scalding.service

import com.twitter.summingbird.scalding._

class EmptyService[K, V] extends Service[K, V] {
  def lookup[W](getKeys: PipeFactory[(K, W)]): PipeFactory[(K, (W, Option[V]))] =
    getKeys.map { _.map { _.map { case (t, (k, v)) => (t, (k, (v, None: Option[V]))) } } }
}

Revert "Empty service as an object"

Revert "Empty service as an object"

This reverts commit 8158cd71bb904d2ad270da0f79ba195cfcfd6779.


// You may use this file to add plugin dependencies for sbt.
resolvers += "bintray-spark-packages" at "https://dl.bintray.com/spark-packages/maven/"

addSbtPlugin("org.spark-packages" %% "sbt-spark-package" % "0.2.2")

// You may use this file to add plugin dependencies for sbt.
resolvers += "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/"

resolvers += "bintray-spark-packages" at "https://dl.bintray.com/spark-packages/maven/"

addSbtPlugin("org.spark-packages" %% "sbt-spark-package" % "0.2.2")

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

Add a dependency of scalastyle sbt plugin


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

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

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

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

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

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

Add scoverage coverage testing plugin

Add scoverage coverage testing plugin

Just for manual use for now


// https://github.com/sbt/sbt/issues/6997
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always

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

// For removing warts, maintain code quality
addSbtPlugin("org.wartremover" %% "sbt-wartremover" % "2.4.20")

// The sbt native packager - needed for docker builds
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.11")

// For code coverage test
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.5")

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

// For formatting Scala source code
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.16")

// Build fat JAR file
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")

// Check vulnerabilities in JAR's
addSbtPlugin("net.vonbuchholtz" % "sbt-dependency-check" % "4.1.0")

// Adds the sbt dependency tree plugin
addDependencyTreePlugin

// https://github.com/sbt/sbt/issues/6997
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always

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

// For removing warts, maintain code quality
addSbtPlugin("org.wartremover" %% "sbt-wartremover" % "2.4.20")

// The sbt native packager - needed for docker builds
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.11")

// For code coverage test
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.5")

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

// For formatting Scala source code
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.16")

// Build fat JAR file
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")

// Check vulnerabilities in JAR's
addSbtPlugin("net.vonbuchholtz" % "sbt-dependency-check" % "4.2.0")

// Adds the sbt dependency tree plugin
addDependencyTreePlugin

Update sbt-dependency-check from 4.1.0 to 4.2.0


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

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

resolvers += "Spark Package Main Repo" at "https://dl.bintray.com/spark-packages/maven"

addSbtPlugin("org.spark-packages" % "sbt-spark-package" % "0.2.5")

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

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

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

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

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

resolvers += "Spark Package Main Repo" at "https://dl.bintray.com/spark-packages/maven"

addSbtPlugin("org.spark-packages" % "sbt-spark-package" % "0.2.6")

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

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

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

Update sbt-spark-package to new version

Update sbt-spark-package to new version


package predictor

import java.io.File

import git._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.sys.process._

/**
 * A provider implementation for the predictor.
 */
class PredictorProvider extends Provider {

  if (!PredictorSettings.validate)
    throw new IllegalArgumentException("Invalid predictor configuration.")

  private var _owner: String = _
  private var _repository: String = _

  def owner = _owner
  def repository = _repository
  def modelDirectory = new File(new File(PredictorSettings.directory, owner), repository).getPath

  override def getTotalDecorator(list: TotalList): TotalList = new PredictorTotalDecorator(list, this)

  override def init(provider: Provider): Future[Unit] = {
    if (provider != null && provider.pullRequestProvider.orNull != null) {
      _owner = provider.pullRequestProvider.get.owner
      _repository = provider.pullRequestProvider.get.repository
    }

    // Make sure the model is trained
    train map { _ => }
  }

  def train = Future(parseCommand("train").! == 0)

  def predict = Future(parseCommand("predict").! == 0)

  private def parseCommand(action: String) = PredictorSettings.command
    .replace("$action", action)
    .replace("$owner", owner)
    .replace("$repository", repository)
}

package predictor

import java.io.File

import git._
import utils.Extensions._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.sys.process._

/**
 * A provider implementation for the predictor.
 */
class PredictorProvider extends Provider {

  if (!PredictorSettings.validate)
    throw new IllegalArgumentException("Invalid predictor configuration.")

  private var _owner: String = _
  private var _repository: String = _

  def owner = _owner
  def repository = _repository
  def modelDirectory = {
    val ownerDir = owner.toLowerCase.safeFileName
    val repoDir = repository.toLowerCase.safeFileName
    new File(new File(PredictorSettings.directory, ownerDir), repoDir).getPath
  }

  override def getTotalDecorator(list: TotalList): TotalList = new PredictorTotalDecorator(list, this)

  override def init(provider: Provider): Future[Unit] = {
    if (provider != null && provider.pullRequestProvider.orNull != null) {
      _owner = provider.pullRequestProvider.get.owner
      _repository = provider.pullRequestProvider.get.repository
    }

    // Make sure the model is trained
    train map { _ => }
  }

  def train = Future(parseCommand("train").! == 0)

  def predict = Future(parseCommand("predict").! == 0)

  private def parseCommand(action: String) = PredictorSettings.command
    .replace("$action", action)
    .replace("$owner", owner)
    .replace("$repository", repository)
}

Write prediction to lowercase directory structure


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

object Build extends android.AutoBuild
{
	lazy val main = Project( "toolbelt", file( "." ) )
		.settings( buildAar: _* )
		.settings(
			libraryDependencies ++= Seq(
				"org.scala-lang" % "scala-reflect" % scalaVersion.value,
				"com.android.support" % "support-v4" % "20.0.0",
				"com.github.japgolly.android" % "svg-android" % "2.0.6"
			),
			name := "Toolbelt",
			organization := "com.taig.android",
			scalaVersion := "2.11.2",
			scalacOptions ++= Seq(
				"-deprecation",
				"-feature",
				"-language:dynamics",
				"-language:implicitConversions",
				"-language:reflectiveCalls"
			),
			version := "0.1.9-BETA",
			libraryProject in Android := true,
			minSdkVersion in Android := "10",
			targetSdkVersion in Android := "21"
		)
}

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

object Build extends android.AutoBuild
{
	lazy val main = Project( "toolbelt", file( "." ) )
		.settings( buildAar: _* )
		.settings(
			libraryDependencies ++= Seq(
				"org.scala-lang" % "scala-reflect" % scalaVersion.value,
				"com.android.support" % "support-v4" % "20.0.0",
				"com.github.japgolly.android" % "svg-android" % "2.0.6"
			),
			name := "Toolbelt",
			organization := "com.taig.android",
			scalaVersion := "2.11.2",
			scalacOptions ++= Seq(
				"-deprecation",
				"-feature",
				"-language:dynamics",
				"-language:implicitConversions",
				"-language:reflectiveCalls"
			),
			version := "0.1.10-BETA",
			libraryProject in Android := true,
			minSdkVersion in Android := "10",
			targetSdkVersion in Android := "21"
		)
}

Set project version to 0.1.10-BETA

Set project version to 0.1.10-BETA


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

val scalaJsVersion = Option(System.getenv("SCALA_JS_VERSION")).getOrElse("1.0.1")

addSbtPlugin("com.typesafe"                      % "sbt-mima-plugin"       % "0.7.0")
addSbtPlugin("com.typesafe.sbt"                  % "sbt-osgi"              % "0.9.5")
addSbtPlugin("com.eed3si9n"                      % "sbt-buildinfo"         % "0.9.0")
addSbtPlugin("com.geirsson"                      % "sbt-ci-release"        % "1.5.3")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings"      % "3.0.0")
addSbtPlugin("org.scoverage"                     % "sbt-scoverage"         % "1.6.1")
addSbtPlugin("org.scala-js"                      % "sbt-scalajs"           % scalaJsVersion)
addSbtPlugin("org.scala-native"                  % "sbt-scala-native"      % "0.4.0-M2")
addSbtPlugin("org.portable-scala"                % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala"                % "sbt-scala-native-crossproject" % "1.0.0")

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

val scalaJsVersion = Option(System.getenv("SCALA_JS_VERSION")).getOrElse("1.1.0")

addSbtPlugin("com.typesafe"                      % "sbt-mima-plugin"       % "0.7.0")
addSbtPlugin("com.typesafe.sbt"                  % "sbt-osgi"              % "0.9.5")
addSbtPlugin("com.eed3si9n"                      % "sbt-buildinfo"         % "0.9.0")
addSbtPlugin("com.geirsson"                      % "sbt-ci-release"        % "1.5.3")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings"      % "3.0.0")
addSbtPlugin("org.scoverage"                     % "sbt-scoverage"         % "1.6.1")
addSbtPlugin("org.scala-js"                      % "sbt-scalajs"           % scalaJsVersion)
addSbtPlugin("org.scala-native"                  % "sbt-scala-native"      % "0.4.0-M2")
addSbtPlugin("org.portable-scala"                % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala"                % "sbt-scala-native-crossproject" % "1.0.0")

Update sbt-scalajs, scalajs-compiler to 1.1.0


addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.11")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

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

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.0.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.11")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.1.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

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

Update sbt-buildinfo to 0.11.0 in master


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

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

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

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

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

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

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


resolvers := Seq(
  "sonatype-snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
  "socrata maven" at "https://repo.socrata.com/artifactory/libs-release/",
  Resolver.sonatypeRepo("releases"),
  Resolver.sonatypeRepo("snapshots"),
  Resolver.bintrayRepo("scalaz", "releases"),
  Resolver.bintrayRepo("megamsys", "scala")
)

addSbtPlugin("com.socrata" % "socrata-sbt-plugins" % "1.6.1")
addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.5.0")
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6")
addSbtPlugin("io.gatling" % "gatling-sbt" % "2.2.0")

resolvers := Seq(
  "sonatype-snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
  "socrata maven" at "https://repo.socrata.com/artifactory/libs-release/",
  Resolver.sonatypeRepo("releases"),
  Resolver.sonatypeRepo("snapshots"),
  Resolver.bintrayRepo("scalaz", "releases")
)

addSbtPlugin("com.socrata" % "socrata-sbt-plugins" % "1.6.1")
addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.5.0")
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6")
addSbtPlugin("io.gatling" % "gatling-sbt" % "2.2.0")

Remove newman bintray resolver thing

Remove newman bintray resolver thing


libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.11"

// https://github.com/coursier/coursier/issues/450
classpathTypes += "maven-plugin"

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.2.4")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.10.0")
addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.4")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.11")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.3")

libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.11"

// https://github.com/coursier/coursier/issues/450
classpathTypes += "maven-plugin"

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.2.4")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.10.0")
addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.5")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.11")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.3")

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


package eu.timepit.refined.scalacheck.util

import org.scalacheck.Prop._
import org.scalacheck.Properties

class OurMathSpec extends Properties("OurMath") {

  property("OurMath.nextAfter == Math.nextAfter") = forAll { (start: Float, direction: Double) =>
    OurMath.nextAfter(start, direction) ?= Math.nextAfter(start, direction)
  }
}

package eu.timepit.refined.scalacheck.util

import org.scalacheck.Prop._
import org.scalacheck.Properties

class OurMathSpec extends Properties("OurMath") {

  property("OurMath.nextAfter == Math.nextAfter (1)") = forAll {
    (start: Float, direction: Double) =>
      OurMath.nextAfter(start, direction) ?= Math.nextAfter(start, direction)
  }

  property("OurMath.nextAfter == Math.nextAfter (2)") = secure {
    val startValues = List(
      +0.0F,
      -0.0F,
      Float.NaN,
      Float.NegativeInfinity,
      Float.PositiveInfinity,
      Float.MinValue,
      Float.MaxValue,
      -Float.MinPositiveValue,
      +Float.MinPositiveValue
    )

    val directionValues = List(
      +0.0,
      -0.0,
      Double.NaN,
      Double.NegativeInfinity,
      Double.PositiveInfinity,
      Double.MinValue,
      Double.MaxValue,
      -Double.MinPositiveValue,
      +Double.MinPositiveValue
    )

    val combinations = startValues.flatMap(s => directionValues.map(d => (s, d)))
    combinations.forall {
      case (start, direction) =>
        val n1 = OurMath.nextAfter(start, direction)
        val n2 = Math.nextAfter(start, direction)
        n1 == n2 || (java.lang.Float.isNaN(n1) && java.lang.Float.isNaN(n2))
    }
  }
}

Improve test coverage of OurMath.nextAfter


/*
 * Copyright (C) 2010 Romain Reuillon
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.openmole.core.model.data

import org.openmole.misc.tools.io.Prettifier._

object Variable {
  def apply[T](p: Prototype[T], v: T) = new Variable[T] {
    val prototype = p
    val value = v
  }
}

trait Variable[T] {
  def prototype: Prototype[T]
  def value: T

  override def toString: String = prettified(Int.MaxValue)

  def prettified(snipArray: Int) = prototype.name + "=" + (if (value != null) value.prettify(snipArray) else "null")
}

/*
 * Copyright (C) 2010 Romain Reuillon
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.openmole.core.model.data

import org.openmole.misc.tools.io.Prettifier._

object Variable {
  def apply[T](p: Prototype[T], v: T) = new Variable[T] {
    val prototype = p
    val value = v
  }

  def unsecure[T](p: Prototype[T], v: Any) = new Variable[T] {
    val prototype = p
    val value = v.asInstanceOf[T]
  }

}

trait Variable[T] {
  def prototype: Prototype[T]
  def value: T

  override def toString: String = prettified(Int.MaxValue)

  def prettified(snipArray: Int) = prototype.name + "=" + (if (value != null) value.prettify(snipArray) else "null")
}

Add unsecure instanciation of variables.


package com.twitter.finatra.http.benchmark

import com.twitter.finagle.Http.{Netty3Impl, Server}
import com.twitter.finagle.http.Request
import com.twitter.finagle.stack.nilStack
import com.twitter.finagle.stats.NullStatsReceiver
import com.twitter.finatra.http.filters.HttpResponseFilter
import com.twitter.finatra.http.routing.HttpRouter
import com.twitter.finatra.http.{Controller, HttpServer}

object FinatraBenchmarkServerMain extends FinatraBenchmarkServer

class FinatraBenchmarkServer extends HttpServer {
  override def configureHttpServer(server: Server): Server = {
    server
      .configured(Netty3Impl)
      .withCompressionLevel(0)
      .withStatsReceiver(NullStatsReceiver)
      .withStack(nilStack)
  }

  override def configureHttp(router: HttpRouter): Unit = {
    router
      .filter[HttpResponseFilter[Request]]
      .add[FinatraBenchmarkController]
  }
}

class FinatraBenchmarkController extends Controller {
  get("/plaintext") { request: Request =>
    "Hello, World!"
  }

  get("/json") { request: Request =>
    Map("message" -> "Hello, World!")
  }
}

package com.twitter.finatra.http.benchmark

import com.twitter.finagle.Http.Server
import com.twitter.finagle.http.Request
import com.twitter.finagle.stack.nilStack
import com.twitter.finagle.stats.NullStatsReceiver
import com.twitter.finatra.http.filters.HttpResponseFilter
import com.twitter.finatra.http.routing.HttpRouter
import com.twitter.finatra.http.{Controller, HttpServer}

object FinatraBenchmarkServerMain extends FinatraBenchmarkServer

class FinatraBenchmarkServer extends HttpServer {
  override def configureHttpServer(server: Server): Server = {
    server
      .withCompressionLevel(0)
      .withStatsReceiver(NullStatsReceiver)
      .withStack(nilStack)
  }

  override def configureHttp(router: HttpRouter): Unit = {
    router
      .filter[HttpResponseFilter[Request]]
      .add[FinatraBenchmarkController]
  }
}

class FinatraBenchmarkController extends Controller {
  get("/plaintext") { request: Request =>
    "Hello, World!"
  }

  get("/json") { request: Request =>
    Map("message" -> "Hello, World!")
  }
}

Remove the Netty3Impl from Http

finagle-netty3-http: Remove the Netty3Impl from Http

Summary: Problem / Solution

We want to drop Netty3 support from the Finagle HTTP
implementation so we delete it.

JIRA Issues: CSL-5976

Differential Revision: https://phabricator.twitter.biz/D136705


package uk.ac.wellcome.platform.idminter.utils

import org.scalatest.{FunSpec, Matchers}
import org.scalatest.prop.PropertyChecks

class IdentifiableTest extends FunSpec with PropertyChecks with Matchers {

  it(
    "should generate a string with 8 characters, none of which are ambiguous characters") {
    forAll(minSuccessful(100)) { (a: Int) =>
      {
        val id = Identifiable.generate
        id should have size (8)
        id.toCharArray should contain noneOf ('0', 'o', 'i', 'l', '1')
        id should fullyMatch regex "[0-9|a-z&&[^oil10]]{8}"
      }
    }
  }

  it("should never generate an identifier that starts with a number") {
    forAll(minSuccessful(100)) { (_: Int) =>
      Identifiable.generate should not(startWith regex "[0-9]")
    }
  }

}

package uk.ac.wellcome.platform.idminter.utils

import org.scalatest.{FunSpec, Matchers}

class IdentifiableTest extends FunSpec with Matchers {

  it("generates an 8-char string, with no ambiguous characters") {
    (1 to 100).map { _ =>
      val id = Identifiable.generate
      id should have size (8)
      id.toCharArray should contain noneOf ('0', 'o', 'i', 'l', '1')
      id should fullyMatch regex "[0-9|a-z&&[^oil10]]{8}"
    }
  }

  it("should never generate an identifier that starts with a number") {
    (1 to 100).map { _ =>
      Identifiable.generate should not(startWith regex "[0-9]")
    }
  }
}

Remove the Scalacheck dependency from the ID minter


import sbt._
import Keys._

import ch.epfl.lamp.sbtscalajs._
import ScalaJSPlugin._
import ScalaJSKeys._

object ScalaJSBuild extends Build {

  val scalajsScalaVersion = "2.10.2"

  val projectSettings = Defaults.defaultSettings ++ Seq(
      organization := "scalajs-benchmarks",
      version := "0.1-SNAPSHOT"
  )

  val defaultSettings = projectSettings ++ scalaJSSettings ++ Seq(
      scalaVersion := scalajsScalaVersion,
      scalacOptions ++= Seq(
          "-deprecation",
          "-unchecked",
          "-feature",
          "-encoding", "utf8"
      )
  )

  lazy val benchmarkSettings = defaultSettings ++ Seq(
      unmanagedSources in (Compile, packageJS) +=
          baseDirectory.value / "exports.js"
  )

  lazy val parent: Project = Project(
      id = "parent",
      base = file("."),
      settings = projectSettings ++ Seq(
          name := "Scala.js Benchmarks",
          publishArtifact in Compile := false,

          clean := clean.dependsOn(
	     clean in common,
	     clean in tracer
	  ).value
      )
  ).aggregate(
      common,
      tracer
  )

  lazy val common = Project(
      id = "common",
      base = file("common"),
      settings = defaultSettings ++ Seq(
          name := "Common - Scala.js Benchmark",
          moduleName := "common"
      )
  )

  lazy val tracer = Project(
      id = "tracer",
      base = file("tracer"),
      settings = benchmarkSettings ++ Seq(
          name := "Tracer - Scala.js Benchmark",
          moduleName := "tracer"
      )
  ).dependsOn(common)
}

import sbt._
import Keys._

import ch.epfl.lamp.sbtscalajs._
import ScalaJSPlugin._
import ScalaJSKeys._

object ScalaJSBuild extends Build {

  val scalajsScalaVersion = "2.10.2"

  val projectSettings = Defaults.defaultSettings ++ Seq(
      organization := "scalajs-benchmarks",
      version := "0.1-SNAPSHOT"
  )

  val defaultSettings = projectSettings ++ scalaJSSettings ++ Seq(
      scalaVersion := scalajsScalaVersion,
      scalacOptions ++= Seq(
          "-deprecation",
          "-unchecked",
          "-feature",
          "-encoding", "utf8"
      )
  )

  lazy val benchmarkSettings = defaultSettings ++ Seq(
      unmanagedSources in (Compile, packageJS) +=
          baseDirectory.value / "exports.js"
  )

  lazy val parent: Project = Project(
      id = "parent",
      base = file("."),
      settings = projectSettings ++ Seq(
          name := "Scala.js Benchmarks",
          publishArtifact in Compile := false,

          clean := clean.dependsOn(
	     clean in common,
	     clean in tracer
	  ).value
      )
  ).aggregate(
      common,
      tracer
  )

  lazy val common = project("Common", defaultSettings)
  lazy val tracer = project("Tracer", benchmarkSettings).dependsOn(common)

  def project(id: String, settings: Seq[sbt.Def.Setting[_]]) = Project(
      id = id.toLowerCase,
      base = file(id.toLowerCase),
      settings = settings ++ Seq(
          name := s"$id - Scala.js Benchmark",
          moduleName := id.toLowerCase
      )
  )
}

Simplify creation of new benchmark projects


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

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


addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.2")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.0.15")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")

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

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.2")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.0.15")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")

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

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


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

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

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

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

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

addSbtPlugin("com.gu" % "sbt-version-info-plugin" % "2.8")

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

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

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

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

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

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

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

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

addSbtPlugin("com.gu" % "sbt-version-info-plugin" % "2.8")

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

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

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

Update sbt-pgp as it breaks with newer versions of native-package

See https://github.com/sbt/sbt-pgp/issues/63


resolvers += Resolver.url("sbt-plugin-snapshots", new URL("http://repo.scala-sbt.org/scalasbt/sbt-plugin-snapshots/"))(Resolver.ivyStylePatterns)

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

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

addSbtPlugin("org.jetbrains" % "sbt-teamcity-logger" % "0.1.0-SNAPSHOT")

Add SBT plugin for TeamCity test logging


/*
 * Copyright 2016 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.gov.hmrc.hmrcemailrenderer.templates.childcareschemesinterest

import uk.gov.hmrc.hmrcemailrenderer.domain.MessageTemplate
import uk.gov.hmrc.hmrcemailrenderer.templates.ServiceIdentifier.Childcare
import uk.gov.hmrc.hmrcemailrenderer.templates.FromAddress.govUkTeamAddress

object ChildcareSchemesInterestTemplates {
  val templates = Seq(
    MessageTemplate.create(
      templateId = "childcare_schemes_interest_email",
      fromAddress = govUkTeamAddress,
      service = Childcare,
      subject = "Your interest new childcare support schemes",
      plainTemplate = txt.csiEmailRegistration.f,
      htmlTemplate = html.csiEmailRegistration.f)
  )
}

/*
 * Copyright 2016 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.gov.hmrc.hmrcemailrenderer.templates.childcareschemesinterest

import uk.gov.hmrc.hmrcemailrenderer.domain.MessageTemplate
import uk.gov.hmrc.hmrcemailrenderer.templates.ServiceIdentifier.Childcare
import uk.gov.hmrc.hmrcemailrenderer.templates.FromAddress.govUkTeamAddress

object ChildcareSchemesInterestTemplates {
  val templates = Seq(
    MessageTemplate.create(
      templateId = "childcare_schemes_interest_email",
      fromAddress = govUkTeamAddress,
      service = Childcare,
      subject = "Your interest in new childcare support schemes",
      plainTemplate = txt.csiEmailRegistration.f,
      htmlTemplate = html.csiEmailRegistration.f)
  )
}

Change header for Childcare Schemes Interest


/*
 * Copyright (C) 2010 Romain Reuillon
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.openmole.core.batch.control

import scala.concurrent.stm._

trait UsageControl {
  def waitAToken: AccessToken
  def tryGetToken: Option[AccessToken]
  def releaseToken(token: AccessToken)
  def available: Int

  def tryWithToken[B](f: Option [AccessToken] => B) = {
    val t = tryGetToken
    try f(t)
    finally t.map(releaseToken)
  }

  def withToken[B](f: (AccessToken ⇒ B)): B = {
    val token = waitAToken
    try f(token)
    finally releaseToken(token)
  }
}

/*
 * Copyright (C) 2010 Romain Reuillon
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.openmole.core.batch.control

import scala.concurrent.stm._

trait UsageControl {
  def waitAToken: AccessToken
  def tryGetToken: Option[AccessToken]
  def releaseToken(token: AccessToken)
  def available: Int

  def tryWithToken[B](f: Option [AccessToken] => B) = {
    val t = tryGetToken
    try f(t)
    finally t.foreach(releaseToken)
  }

  def withToken[B](f: (AccessToken ⇒ B)): B = {
    val token = waitAToken
    try f(token)
    finally releaseToken(token)
  }
}

Use foreach instead of map.

Use foreach instead of map.


package com.linkedin.sleipnir.sbt

import com.linkedin.sleipnir.Sleipnir

import sbt._
import Keys._

object SleipnirPlugin extends Plugin {

  val sleipnirGenerator = taskKey[Seq[File]]("Sleipnir generator")

  lazy val sleipnirSettings: Seq[Def.Setting[_]] = Seq(
    sleipnirGenerator in Compile := {
      val src = sourceDirectory.value / "main" / "pegasus"
      val dst = sourceManaged.value
      runSleipnirGenerator(src, dst)
    },
    sourceGenerators in Compile <+= (sleipnirGenerator in Compile)
  )

  def runSleipnirGenerator(src: File, dst: File): Seq[File] = {
    Sleipnir.run(src.toString, src, dst)
  }
}

package com.linkedin.sleipnir.sbt

import com.linkedin.sleipnir.Sleipnir

import sbt._
import Keys._
import java.io.File.pathSeparator

object SleipnirPlugin extends Plugin {

  val sleipnirGenerator = taskKey[Seq[File]]("Sleipnir generator")

  lazy val sleipnirSettings: Seq[Def.Setting[_]] = Seq(
    sleipnirGenerator in Compile := {
      val src = sourceDirectory.value / "main" / "pegasus"
      val dst = sourceManaged.value
      val resolverPathFiles = Seq(src.getAbsolutePath) ++
        (managedClasspath in Compile).value.map(_.data.getAbsolutePath) ++
        (internalDependencyClasspath in Compile).value.map(_.data.getAbsolutePath) // adds in .pdscs from projects that this project .dependsOn
      val resolverPath = resolverPathFiles.mkString(pathSeparator)

      runSleipnirGenerator(resolverPath, src, dst)
    },
    sourceGenerators in Compile <+= (sleipnirGenerator in Compile)
  )

  def runSleipnirGenerator(resolverPath: String, src: File, dst: File): Seq[File] = {
    Sleipnir.run(resolverPath, src, dst)
  }
}

Add managed classpath and internal dependency classpath to resolver path for plugin.


import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "elasticsearch-sample"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      // Add your project dependencies here,
      "com.github.nboire" % "elasticsearch_2.9.1" % "1.0"
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
      // Add your own project settings here
      resolvers += "Local Play Repository" at "file://Users/nboire/dev/java/play/play-2.0/repository/local"
      //resolvers += "Local Play Repository" at "file://path/to/play-2.0/repository/local"

    )

}

import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "elasticsearch-sample"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
      // Add your project dependencies here,
      "com.github.nboire" % "elasticsearch_2.9.1" % "1.0"
    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
      // Add your own project settings here
      resolvers += "Local Play Repository" at "file://Users/nboire/dev/java/play/play-2.0/repository/local"
      //resolvers += Resolver.url("GitHub Play2-elasticsearch Repository", url("http://nboire.github.com/play2-elasticsearch/releases/"))(Resolver.ivyStylePatterns)
    )

}

Test sample with local repository

Test sample with local repository


package org.opencypher.tools.tck

import java.util

import cypher.features.InterpretedTCKTests
import org.junit.jupiter.api.DynamicTest
import org.junit.jupiter.api.TestFactory

class TCKImplementationTest {
  @TestFactory
  def runNeo4j(): util.Collection[DynamicTest] =
    (new InterpretedTCKTests()).runInterpreted()
}

/*
 * Copyright (c) 2015-2020 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Attribution Notice under the terms of the Apache License 2.0
 *
 * This work was created by the collective efforts of the openCypher community.
 * Without limiting the terms of Section 6, any Derivative Work that is not
 * approved by the public consensus process of the openCypher Implementers Group
 * should not be described as “Cypher” (and Cypher® is a registered trademark of
 * Neo4j Inc.) or as "openCypher". Extensions by implementers or prototypes or
 * proposals for change that have been documented or implemented should only be
 * described as "implementation extensions to Cypher" or as "proposed changes to
 * Cypher that are not yet approved by the openCypher community".
 */
package org.opencypher.tools.tck

import java.util

import cypher.features.InterpretedTCKTests
import org.junit.jupiter.api.{Disabled, DynamicTest, TestFactory}

class TCKImplementationTest {
  @TestFactory @Disabled
  def runTckOnNeo4j(): util.Collection[DynamicTest] = new InterpretedTCKTests().runInterpreted()
}

Add test to run TCK on Neo4j

Add test to run TCK on Neo4j


/*
 * Copyright 2005-2009 LAMP/EPFL
 */
// $Id$

package scala.tools.eclipse.util

import scala.tools.nsc.Settings

object IDESettings {
  def shownSettings(s : Settings) : List[Settings.Setting]= {
    import s._
    List(
      deprecation, debuginfo, XO, target, unchecked,
      Xchecknull, checkInit, noassertions, Xexperimental, future, XlogImplicits, nouescape, XnoVarargsConversion, pluginsDir, Xwarninit,
      Xcloselim, Xdce, Xdetach, inline, Xlinearizer, Ynogenericsig, noimports, nopredefs, selfInAnnots, Xwarndeadcode, specialize)
  }
}

/*
 * Copyright 2005-2009 LAMP/EPFL
 */
// $Id$

package scala.tools.eclipse.util

import scala.tools.nsc.Settings

object IDESettings {
  def shownSettings(s : Settings) : List[Settings.Setting]= {
    import s._
    List(
      deprecation, debuginfo, XO, target, unchecked,
      checkInit, noassertions, elideLevel, Xexperimental, future, XlogImplicits, nouescape, XnoVarargsConversion, pluginsDir,
      Xcloselim, Xdce, Xdetach, inline, Xlinearizer, Ynogenericsig, noimports, nopredefs, selfInAnnots, Xsqueeze, specialize, Ytailrec,
      Xwarninit, Xchecknull, Xwarndeadcode, YwarnShadow, YwarnCatches, Xwarnings)
  }
}

Update list of scalac settings exposed by the IDE.

git-svn-id: d518d5b67c3faf3e6f0db4ab9fe5fb399964ea1a@19277 5e8d7ff9-d8ef-0310-90f0-a4852d11357a


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.13.0",
  "org.http4s" %% "http4s-blaze-client" % "0.21.7",
  "org.http4s" %% "http4s-circe" % "0.21.7",
)

// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.3.24"

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.13.0",
  "org.http4s" %% "http4s-blaze-client" % "0.21.8",
  "org.http4s" %% "http4s-circe" % "0.21.8",
)

// Hack around a binary conflict in scalameta's dependency on
// fastparse as specified by sbt-doctest-0.9.5.
libraryDependencies += "org.scalameta" %% "scalameta" % "4.3.24"

Update http4s-blaze-client, ... to 0.21.8


import sbt._
import Keys._

import com.socrata.cloudbeessbt.SocrataCloudbeesSbt
import com.typesafe.tools.mima.plugin.MimaKeys._

object BuildSettings {
  val cloudbees = "https://repository-socrata-oss.forge.cloudbees.com/"
  val cloudbeesSnapshots = "snapshots" at cloudbees + "snapshot"
  val cloudbeesReleases = "releases" at cloudbees + "release"

  val buildSettings: Seq[Setting[_]] = Defaults.defaultSettings ++ SocrataCloudbeesSbt.socrataBuildSettings ++ Seq(
    scalaVersion := "2.10.4"
  )

  val projectSettings: Seq[Setting[_]] = buildSettings ++ SocrataCloudbeesSbt.socrataProjectSettings() ++ Seq(
    previousArtifact <<= (scalaBinaryVersion, name) { (sv, name) => Some("com.socrata" % (name + "_" + sv) % "2.2.0") },
    testOptions in Test ++= Seq(
      Tests.Argument(TestFrameworks.ScalaTest, "-oFD")
    ),
    libraryDependencies ++= Seq(
      Dependencies.scalaTest % "test"
    ),
    scalacOptions ++= Seq("-language:implicitConversions")
  )
}

import sbt._
import Keys._

import com.socrata.cloudbeessbt.SocrataCloudbeesSbt
import com.typesafe.tools.mima.plugin.MimaKeys._

object BuildSettings {
  val cloudbees = "https://repository-socrata-oss.forge.cloudbees.com/"
  val cloudbeesSnapshots = "snapshots" at cloudbees + "snapshot"
  val cloudbeesReleases = "releases" at cloudbees + "release"

  val buildSettings: Seq[Setting[_]] = Defaults.defaultSettings ++ SocrataCloudbeesSbt.socrataBuildSettings ++ Seq(
    scalaVersion := "2.10.4"
  )

  val projectSettings: Seq[Setting[_]] = buildSettings ++ SocrataCloudbeesSbt.socrataProjectSettings() ++ Seq(
    previousArtifact <<= (scalaBinaryVersion, name) { (sv, name) => Some("com.socrata" % (name + "_" + sv) % "2.3.0") },
    testOptions in Test ++= Seq(
      Tests.Argument(TestFrameworks.ScalaTest, "-oFD")
    ),
    libraryDependencies ++= Seq(
      Dependencies.scalaTest % "test"
    ),
    scalacOptions ++= Seq("-language:implicitConversions")
  )
}

Update previousArtifact (soon this will be done automatically by sbt-release)


package uk.ac.wellcome.platform.sierra_items_to_dynamo.services

import akka.actor.ActorSystem
import com.google.inject.Inject
import uk.ac.wellcome.messaging.sns.{NotificationMessage, SNSWriter}
import uk.ac.wellcome.messaging.sqs.SQSStream
import uk.ac.wellcome.models.transformable.sierra.SierraItemRecord
import uk.ac.wellcome.json.JsonUtil._

import scala.concurrent.{ExecutionContext, Future}

class SierraItemsToDynamoWorkerService @Inject()(
  system: ActorSystem,
  sqsStream: SQSStream[NotificationMessage],
  dynamoInserter: DynamoInserter,
  snsWriter: SNSWriter
)(implicit ec: ExecutionContext) {

  sqsStream.foreach(this.getClass.getSimpleName, process)

  private def process(message: NotificationMessage): Future[Unit] =
    for {
      itemRecord <- Future.fromTry(fromJson[SierraItemRecord](message.Message))
      hybridRecord <- dynamoInserter.insertIntoDynamo(itemRecord)
      _ <- snsWriter.writeMessage(
        message = hybridRecord.location,
        subject = s"Sent from ${this.getClass.getSimpleName}"
      )
    } yield ()

  def stop() = system.terminate()
}

package uk.ac.wellcome.platform.sierra_items_to_dynamo.services

import akka.actor.ActorSystem
import com.google.inject.Inject
import uk.ac.wellcome.messaging.sns.{NotificationMessage, SNSWriter}
import uk.ac.wellcome.messaging.sqs.SQSStream
import uk.ac.wellcome.models.transformable.sierra.SierraItemRecord
import uk.ac.wellcome.json.JsonUtil._
import uk.ac.wellcome.messaging.message.{MessageNotification, RemoteNotification}

import scala.concurrent.{ExecutionContext, Future}

class SierraItemsToDynamoWorkerService @Inject()(
  system: ActorSystem,
  sqsStream: SQSStream[NotificationMessage],
  dynamoInserter: DynamoInserter,
  snsWriter: SNSWriter
)(implicit ec: ExecutionContext) {

  sqsStream.foreach(this.getClass.getSimpleName, process)

  private def process(message: NotificationMessage): Future[Unit] =
    for {
      itemRecord <- Future.fromTry(fromJson[SierraItemRecord](message.Message))
      hybridRecord <- dynamoInserter.insertIntoDynamo(itemRecord)
      _ <- snsWriter.writeMessage[MessageNotification](
        message = RemoteNotification(hybridRecord.location),
        subject = s"Sent from ${this.getClass.getSimpleName}"
      )
    } yield ()

  def stop() = system.terminate()
}

Write a RemoteLocation from sierra_items_to_dynamo


name := "l_space"

version := "0.0.1-WORKPRINT"

scalaVersion := "2.11.7"

mainClass := Some("org.mediachain.LSpace")

libraryDependencies ++= Seq(
  "com.michaelpollmeier" % "gremlin-scala_2.11" % "3.1.0-incubating.1",
  "org.typelevel" %% "cats" % "0.4.1",
  "org.specs2" %% "specs2-core" % "3.7" % "test"
)

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

name := "l_space"

version := "0.0.1-WORKPRINT"

scalaVersion := "2.11.7"

mainClass := Some("org.mediachain.LSpace")

libraryDependencies ++= Seq(
  "com.michaelpollmeier" % "gremlin-scala_2.11" % "3.1.0-incubating.1",
  "com.michaelpollmeier" % "orientdb-gremlin" % "3.1.0-incubating.1",
  "com.tinkerpop.blueprints" % "blueprints-core" % "2.6.0",
  "org.typelevel" %% "cats" % "0.4.1",
  "com.chuusai" %% "shapeless" % "2.2.5",
  "org.specs2" %% "specs2-core" % "3.7" % "test"
)

Add orientdb-gremlin, shapeless & blueprints


package uk.ac.wellcome.models.transformable.sierra

import java.time.Instant

case class SierraItemRecord(
  id: String,
  data: String,
  modifiedDate: Instant,
  bibIds: List[String],
  unlinkedBibIds: List[String] = List(),
  version: Int = 0
)

object SierraItemRecord {
  def apply(id: String,
            data: String,
            modifiedDate: String,
            bibIds: List[String]): SierraItemRecord =
    SierraItemRecord(
      id = id,
      data = data,
      modifiedDate = Instant.parse(modifiedDate),
      bibIds = bibIds
    )
}

Remove an unused apply method

Remove an unused apply method


package uk.ac.wellcome.finatra.storage

import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder}
import com.google.inject.Provides
import com.twitter.inject.TwitterModule
import javax.inject.Singleton
import uk.ac.wellcome.models.aws.AWSConfig
import uk.ac.wellcome.storage.s3.S3ClientFactory

object S3ClientModule extends TwitterModule {

  private val endpoint = flag[String](
    "aws.s3.endpoint",
    "",
    "Endpoint of AWS S3. The region will be used if the endpoint is not provided")
  private val accessKey =
    flag[String]("aws.s3.accessKey", "", "AccessKey to access S3")
  private val secretKey =
    flag[String]("aws.s3.secretKey", "", "SecretKey to access S3")

  @Singleton
  @Provides
  def providesS3Client(awsConfig: AWSConfig): AmazonS3 =
    buildS3Client(
      awsConfig = awsConfig,
      endpoint = endpoint(),
      accessKey = accessKey(),
      secretKey = secretKey()
    )

  def buildS3Client(awsConfig: AWSConfig,
                    endpoint: String,
                    accessKey: String,
                    secretKey: String): AmazonS3 =
    S3ClientFactory.create(
      region = awsConfig.region,
      endpoint = endpoint,
      accessKey = accessKey,
      secretKey = secretKey
    )
}

package uk.ac.wellcome.finatra.storage

import javax.inject.Singleton

import com.amazonaws.services.s3.AmazonS3
import com.google.inject.Provides
import com.twitter.inject.TwitterModule
import uk.ac.wellcome.models.aws.AWSConfig
import uk.ac.wellcome.storage.s3.S3ClientFactory

object S3ClientModule extends TwitterModule {

  private val endpoint = flag[String](
    "aws.s3.endpoint",
    "",
    "Endpoint of AWS S3. The region will be used if the endpoint is not provided")
  private val accessKey =
    flag[String]("aws.s3.accessKey", "", "AccessKey to access S3")
  private val secretKey =
    flag[String]("aws.s3.secretKey", "", "SecretKey to access S3")

  @Singleton
  @Provides
  def providesS3Client(awsConfig: AWSConfig): AmazonS3 =
    S3ClientFactory.create(
      region = awsConfig.region,
      endpoint = endpoint(),
      accessKey = accessKey(),
      secretKey = secretKey()
    )
}

Tidy up the S3Client module as well

Tidy up the S3Client module as well


package scala.meta.internal.semanticdb.scalac

import scala.reflect.internal.util.Position
import scala.tools.nsc.reporters.{Reporter, StoreReporter}

class SemanticdbReporter(underlying: Reporter) extends StoreReporter {
  override protected def info0(
      pos: Position,
      msg: String,
      severity: Severity,
      force: Boolean
  ): Unit = {
    super.info0(pos, msg, severity, force)
    severity.id match {
      case 0 => underlying.info(pos, msg, force)
      case 1 => underlying.warning(pos, msg)
      case 2 => underlying.error(pos, msg)
      case _ =>
    }
    // underlying reporter may have filtered out the message
    updateCounts()
  }

  private def updateCounts(): Unit = {
    INFO.count = underlying.INFO.count
    WARNING.count = underlying.WARNING.count
    ERROR.count = underlying.ERROR.count
  }
}

package scala.meta.internal.semanticdb.scalac

import scala.reflect.internal.util.Position
import scala.tools.nsc.reporters.{Reporter, StoreReporter}

class SemanticdbReporter(underlying: Reporter) extends StoreReporter {
  override protected def info0(
      pos: Position,
      msg: String,
      severity: Severity,
      force: Boolean
  ): Unit = {
    super.info0(pos, msg, severity, force)
    severity.id match {
      case 0 => underlying.info(pos, msg, force)
      case 1 => underlying.warning(pos, msg)
      case 2 => underlying.error(pos, msg)
      case _ =>
    }

  }

  override def hasErrors: Boolean = underlying.hasErrors

  override def hasWarnings: Boolean = underlying.hasWarnings

}

Fix compile error reporting when using smenaticdb plugin


package lore

import lore.ast._
import lore.exceptions.FunctionNotFoundException
import lore.execution.Context
import lore.parser.{FileParser, FpExpressionParser}

import scala.io.Source

object Lore {
  def testCalculation(): Unit = {
    val source = Source.fromFile("examples/calculation.lore").getLines.mkString
    val parser = new FpExpressionParser()
    val expression = parser.parseExpression(source)
    val result = ExprAlgebra.evaluate(ExprAlgebra.evalAlgebra)(expression)
    println("FP  result: " + result)
  }

  def main(args: Array[String]): Unit = {
    // A new line is added at the end so the last statement has a closing newline.
    val source = Source.fromFile("examples/concat.lore").getLines.filter(_.trim.nonEmpty).mkString("\n") + "\n"
    println(source)
    val parser = new FileParser()
    val elements = parser.parse(source)

    println()
    println("Elements: ")
    elements.foreach(println)

    val context = Context.build(elements)

    println()
    println("Function fit for each call statement:")
    context.calls.foreach { call =>
      val multiFunction = context.multiFunctions.getOrElse(call.functionName, throw FunctionNotFoundException(call.functionName))
      val fit = multiFunction.fit(call.argumentType)
      val min = fit.multiMin
      println(s"Fit: $fit")
      println(s"Min: $min")
      println()
    }
  }
}

package lore

import lore.ast._
import lore.exceptions.FunctionNotFoundException
import lore.execution.Context
import lore.parser.{FileParser, FpExpressionParser}

import scala.io.Source

object Lore {
  def testCalculation(): Unit = {
    val source = Source.fromFile("examples/calculation.lore").getLines.mkString
    val parser = new FpExpressionParser()
    val expression = parser.parseExpression(source)
    val result = ExprAlgebra.evaluate(ExprAlgebra.evalAlgebra)(expression)
    println("FP  result: " + result)
  }

  def main(args: Array[String]): Unit = {
    // A new line is added at the end so the last statement has a closing newline.
    val source = Source.fromFile(s"examples/${args(0)}.lore").getLines.filter(_.trim.nonEmpty).mkString("\n") + "\n"
    println(source)
    val parser = new FileParser()
    val elements = parser.parse(source)

    println()
    println("Elements: ")
    elements.foreach(println)

    val context = Context.build(elements)

    println()
    println("Function fit for each call statement:")
    context.calls.foreach { call =>
      val multiFunction = context.multiFunctions.getOrElse(call.functionName, throw FunctionNotFoundException(call.functionName))
      val fit = multiFunction.fit(call.argumentType)
      val min = fit.multiMin
      println(s"Fit: $fit")
      println(s"Min: $min")
      println()
    }
  }
}

Allow execution of any example from the example folder.


package com.microsoft.partnercatalyst.fortis.spark.transforms.language

import com.microsoft.partnercatalyst.fortis.spark.logging.FortisTelemetry
import com.optimaize.langdetect.LanguageDetectorBuilder
import com.optimaize.langdetect.ngram.NgramExtractors
import com.optimaize.langdetect.profiles.LanguageProfileReader
import com.optimaize.langdetect.text.{CommonTextObjectFactories, TextObjectFactory}

@SerialVersionUID(100L)
class LocalLanguageDetector extends LanguageDetector {
  @transient private lazy val languageProfiles = new LanguageProfileReader().readAllBuiltIn
  @transient private lazy val languageDetector = LanguageDetectorBuilder.create(NgramExtractors.standard()).withProfiles(languageProfiles).build()
  @transient private lazy val largeTextFactory = CommonTextObjectFactories.forDetectingOnLargeText()
  @transient private lazy val shortTextFactory = CommonTextObjectFactories.forDetectingShortCleanText()

  override def detectLanguage(text: String): Option[String] = {
    if (text.isEmpty) {
      return None
    }

    var language = detectWithFactory(text, shortTextFactory)
    if (language.isEmpty) language = detectWithFactory(text, largeTextFactory)

    FortisTelemetry.get().logLanguageDetection(language)
    language
  }

  private def detectWithFactory(text: String, factory: TextObjectFactory): Option[String] = {
    Option(languageDetector.detect(factory.forText(text)).orNull).map(_.getLanguage)
  }
}

package com.microsoft.partnercatalyst.fortis.spark.transforms.language

import com.microsoft.partnercatalyst.fortis.spark.logging.FortisTelemetry
import com.optimaize.langdetect.LanguageDetectorBuilder
import com.optimaize.langdetect.ngram.NgramExtractors
import com.optimaize.langdetect.profiles.LanguageProfileReader
import com.optimaize.langdetect.text.{CommonTextObjectFactories, TextObjectFactory}

@SerialVersionUID(100L)
class LocalLanguageDetector extends LanguageDetector {
  @transient private lazy val languageProfiles = new LanguageProfileReader().readAllBuiltIn
  @transient private lazy val languageDetector = LanguageDetectorBuilder.create(NgramExtractors.standard()).withProfiles(languageProfiles).build()
  @transient private lazy val largeTextFactory = CommonTextObjectFactories.forDetectingOnLargeText()
  @transient private lazy val shortTextFactory = CommonTextObjectFactories.forDetectingShortCleanText()

  override def detectLanguage(text: String): Option[String] = {
    if (text.isEmpty) {
      return None
    }

    val language = detectWithFactory(text, if (text.length <= 200) shortTextFactory else largeTextFactory)

    FortisTelemetry.get().logLanguageDetection(language)
    language
  }

  private def detectWithFactory(text: String, factory: TextObjectFactory): Option[String] = {
    Option(languageDetector.detect(factory.forText(text)).orNull).map(_.getLanguage)
  }
}

Switch factory based on text length

Switch factory based on text length