diff --git a/.travis.yml b/.travis.yml index 9aeebb04..64cc6bf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,8 @@ jdk: - oraclejdk8 scala: - - 2.11.11 - - 2.12.2 + - 2.11.12 + - 2.12.6 before_script: cd scala diff --git a/scala/README.md b/scala/README.md index fb58d6cb..f1e1e7fb 100644 --- a/scala/README.md +++ b/scala/README.md @@ -2,12 +2,12 @@ Revenj.Scala ============ [![Build Status](https://travis-ci.org/ngs-doo/revenj.svg?branch=travis)](https://travis-ci.org/ngs-doo/revenj) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.revenj/revenj-core_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.revenj/revenj-core_2.11) -[![Scaladoc](https://javadoc-badge.appspot.com/net.revenj/revenj-core_2.11.svg?label=scaladoc)](http://javadoc-badge.appspot.com/net.revenj/revenj-core_2.11) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.revenj/revenj-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.revenj/revenj-core_2.12) +[![Scaladoc](https://javadoc-badge.appspot.com/net.revenj/revenj-core_2.12.svg?label=scaladoc)](http://javadoc-badge.appspot.com/net.revenj/revenj-core_2.12) [![License](https://img.shields.io/badge/license-BSD%203--Clause-brightgreen.svg)](https://opensource.org/licenses/BSD-3-Clause) **revenj.scala** is available on OSSRH / Maven Central: ```scala -libraryDependencies += "net.revenj" %% "revenj-core" % "0.6.3" +libraryDependencies += "net.revenj" %% "revenj-core" % "0.7.1" ``` diff --git a/scala/build.sbt b/scala/build.sbt index d8a9ab2f..6f6612d1 100644 --- a/scala/build.sbt +++ b/scala/build.sbt @@ -4,7 +4,7 @@ lazy val core = (project in file("revenj-core") settings (commonSettings ++ publishSettings) enablePlugins(SbtDslPlatformPlugin) settings( - version := "0.7.0", + version := "0.7.1", libraryDependencies ++= Seq( "org.postgresql" % "postgresql" % "42.1.4", "joda-time" % "joda-time" % "2.9.9", // TODO: will be removed @@ -12,7 +12,7 @@ lazy val core = (project in file("revenj-core") "org.scala-lang" % "scala-reflect" % scalaVersion.value, "io.monix" %% "monix-reactive" % "2.3.2", "org.scala-lang.modules" %% "scala-xml" % "1.0.6", - "com.dslplatform" %% "dsl-json-scala" % "1.7.3", + "com.dslplatform" %% "dsl-json-scala" % "1.7.4", "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.4", "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.4", "com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % "2.9.4", @@ -26,7 +26,7 @@ lazy val core = (project in file("revenj-core") lazy val akka = (project in file("revenj-akka") settings (commonSettings ++ publishSettings) settings( - version := "0.7.0", + version := "0.7.1", libraryDependencies ++= Seq( "com.typesafe" % "config" % "1.3.2", "com.typesafe.akka" %% "akka-http-core" % "10.0.13" @@ -91,7 +91,7 @@ lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq( name := baseDirectory.value.getName, scalaVersion := crossScalaVersions.value.head, - crossScalaVersions := Seq("2.11.12", "2.12.5"), + crossScalaVersions := Seq("2.11.12", "2.12.6"), scalacOptions ++= Seq( "-deprecation", "-encoding", "UTF-8", diff --git a/scala/project/build.sbt b/scala/project/build.sbt index 37b29bb2..6494529f 100644 --- a/scala/project/build.sbt +++ b/scala/project/build.sbt @@ -1,4 +1,4 @@ -scalaVersion := "2.12.5" +scalaVersion := "2.12.6" scalacOptions ++= Seq( "-deprecation", diff --git a/scala/project/plugins.sbt b/scala/project/plugins.sbt index 67d2c8a9..1c22b015 100644 --- a/scala/project/plugins.sbt +++ b/scala/project/plugins.sbt @@ -1,4 +1,4 @@ logLevel := Level.Warn addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1") -addSbtPlugin("com.dslplatform" % "sbt-dsl-platform" % "0.7.2") +addSbtPlugin("com.dslplatform" % "sbt-dsl-platform" % "0.7.3") diff --git a/scala/revenj-akka/src/main/scala/net/revenj/server/RevenjSerialization.scala b/scala/revenj-akka/src/main/scala/net/revenj/server/RevenjSerialization.scala index ca56f5d5..b0a70af5 100644 --- a/scala/revenj-akka/src/main/scala/net/revenj/server/RevenjSerialization.scala +++ b/scala/revenj-akka/src/main/scala/net/revenj/server/RevenjSerialization.scala @@ -26,16 +26,16 @@ private[revenj] class RevenjSerialization(jackson: JacksonSerialization, loader: } override def deserialize[T: TypeTag](content: Array[Byte], length: Int, contentType: String): Try[T] = { - Utils.findType(typeOf[T], mirror) match { + Utils.findType(mirror.typeOf[T], mirror) match { case Some(tpe) => deserialize(tpe, content, length, contentType).map(_.asInstanceOf[T]) - case _ => Failure(new IllegalArgumentException("Unable to find Java type for: " + typeOf[T])) + case _ => Failure(new IllegalArgumentException(s"Unable to find Java type for: ${mirror.typeOf[T]}")) } } override def deserialize[T: TypeTag](stream: InputStream, contentType: String): Try[T] = { - Utils.findType(typeOf[T], mirror) match { + Utils.findType(mirror.typeOf[T], mirror) match { case Some(tpe) => deserialize(tpe, stream, contentType).map(_.asInstanceOf[T]) - case _ => Failure(new IllegalArgumentException("Unable to find Java type for: " + typeOf[T])) + case _ => Failure(new IllegalArgumentException(s"Unable to find Java type for: ${mirror.typeOf[T]}")) } } diff --git a/scala/revenj-core/src/main/scala/net/revenj/LocatorDataContext.scala b/scala/revenj-core/src/main/scala/net/revenj/LocatorDataContext.scala index 6aec5f17..4e14110d 100644 --- a/scala/revenj-core/src/main/scala/net/revenj/LocatorDataContext.scala +++ b/scala/revenj-core/src/main/scala/net/revenj/LocatorDataContext.scala @@ -63,9 +63,9 @@ private[revenj] class LocatorDataContext( } private def findManifest[T: TypeTag]: Class[_] = { - typeOf[T] match { + mirror.typeOf[T] match { case TypeRef(_, sym, _) => mirror.runtimeClass(sym.asClass) - case _ => throw new ReflectiveOperationException("Unable to find class type for " + typeOf[T]) + case _ => throw new ReflectiveOperationException(s"Unable to find class type for ${mirror.typeOf[T]}") } } diff --git a/scala/revenj-core/src/main/scala/net/revenj/Revenj.scala b/scala/revenj-core/src/main/scala/net/revenj/Revenj.scala index b3cbbb1b..5d24e52b 100644 --- a/scala/revenj-core/src/main/scala/net/revenj/Revenj.scala +++ b/scala/revenj-core/src/main/scala/net/revenj/Revenj.scala @@ -183,13 +183,14 @@ If you wish to use custom jdbc driver provide custom data source instead of usin } def registerEvents[T <: DomainEvent : TypeTag](container: Container, plugins: PluginLoader, loader: ClassLoader): Unit = { - val javaClass = Utils.findType(typeOf[T], runtimeMirror(loader)) match { + val mirror = runtimeMirror(loader) + val javaClass = Utils.findType(mirror.typeOf[T], mirror) match { case Some(p) => p match { case cl: Class[_] => cl - case _ => throw new IllegalArgumentException(s"Only non-generic types supported. Found: ${typeOf[T]}") + case _ => throw new IllegalArgumentException(s"Only non-generic types supported. Found: ${mirror.typeOf[T]}") } - case _ => throw new IllegalArgumentException(s"Unable to detect type: ${typeOf[T]}") + case _ => throw new IllegalArgumentException(s"Unable to detect type: ${mirror.typeOf[T]}") } def processHandlers[X: TypeTag](gt: ParameterizedType, eventHandlers: Seq[Class[DomainEventHandler[X]]]): Unit = { eventHandlers foreach { h => @@ -220,7 +221,8 @@ If you wish to use custom jdbc driver provide custom data source instead of usin } def registerReports[R : TypeTag, T <: Report[R] : TypeTag](container: Container, plugins: PluginLoader, loader: ClassLoader): Unit = { - val resultClass = Utils.findType(typeOf[R], runtimeMirror(loader)) match { + val mirror = runtimeMirror(loader) + val resultClass = Utils.findType(mirror.typeOf[R], mirror) match { case Some(p) => p match { case cl: Class[_] => cl @@ -228,13 +230,13 @@ If you wish to use custom jdbc driver provide custom data source instead of usin } case _ => throw new IllegalArgumentException(s"Unable to detect type: ${typeOf[R]}") } - val reportClass = Utils.findType(typeOf[T], runtimeMirror(loader)) match { + val reportClass = Utils.findType(mirror.typeOf[T], mirror) match { case Some(p) => p match { case cl: Class[_] => cl - case _ => throw new IllegalArgumentException(s"Only non-generic types supported. Found: ${typeOf[T]}") + case _ => throw new IllegalArgumentException(s"Only non-generic types supported. Found: ${mirror.typeOf[T]}") } - case _ => throw new IllegalArgumentException(s"Unable to detect type: ${typeOf[T]}") + case _ => throw new IllegalArgumentException(s"Unable to detect type: ${mirror.typeOf[T]}") } val gt = Utils.makeGenericType(classOf[ReportAspect[_, _]], resultClass, reportClass) val aspects = plugins.find[ReportAspect[R, T]] @@ -245,13 +247,14 @@ If you wish to use custom jdbc driver provide custom data source instead of usin } def registerAggregates[T <: AggregateRoot : TypeTag](container: Container, plugins: PluginLoader, loader: ClassLoader): Unit = { - val javaClass = Utils.findType(typeOf[T], runtimeMirror(loader)) match { + val mirror = runtimeMirror(loader) + val javaClass = Utils.findType(mirror.typeOf[T], mirror) match { case Some(p) => p match { case cl: Class[_] => cl - case _ => throw new IllegalArgumentException(s"Only non-generic types supported. Found: ${typeOf[T]}") + case _ => throw new IllegalArgumentException(s"Only non-generic types supported. Found: ${mirror.typeOf[T]}") } - case _ => throw new IllegalArgumentException(s"Unable to detect type: ${typeOf[T]}") + case _ => throw new IllegalArgumentException(s"Unable to detect type: ${mirror.typeOf[T]}") } val gt = Utils.makeGenericType(classOf[PersistableRepositoryAspect[_]], javaClass) val aspects = plugins.find[PersistableRepositoryAspect[T]] diff --git a/scala/revenj-core/src/main/scala/net/revenj/SimpleContainer.scala b/scala/revenj-core/src/main/scala/net/revenj/SimpleContainer.scala index d7eda785..b3ceff47 100644 --- a/scala/revenj-core/src/main/scala/net/revenj/SimpleContainer.scala +++ b/scala/revenj-core/src/main/scala/net/revenj/SimpleContainer.scala @@ -240,7 +240,7 @@ private[revenj] class SimpleContainer private(private val parent: Option[SimpleC } override def tryResolve[T: TypeTag]: Try[T] = { - Utils.findType(typeOf[T], mirror) match { + Utils.findType(mirror.typeOf[T], mirror) match { case Some(tpe) => resolve(tpe).map(_.asInstanceOf[T]) case _ => Failure(new ReflectiveOperationException("Invalid type tag argument")) } @@ -472,17 +472,17 @@ If you wish to resolve types not registered in the container, specify revenj.res if (handleClose && service.isInstanceOf[AutoCloseable]) { closeables.add(service.asInstanceOf[AutoCloseable]) } - val paramType = Utils.findType(typeOf[T], mirror).getOrElse(throw new IllegalArgumentException(s"Unable to register ${typeOf[T]} to container")) + val paramType = Utils.findType(mirror.typeOf[T], mirror).getOrElse(throw new IllegalArgumentException(s"Unable to register ${mirror.typeOf[T]} to container")) addToRegistry(new Registration[T](paramType, this, service, false)) } override def registerFunc[T: TypeTag](factory: Container => T, lifetime: InstanceScope = Transient): this.type = { - val paramType = Utils.findType(typeOf[T], mirror).getOrElse(throw new IllegalArgumentException(s"Unable to register ${typeOf[T]} to container")) + val paramType = Utils.findType(mirror.typeOf[T], mirror).getOrElse(throw new IllegalArgumentException(s"Unable to register ${mirror.typeOf[T]} to container")) addToRegistry(new Registration[T](paramType, this, factory, lifetime)) } override def registerGenerics[T: TypeTag](factory: (Container, Array[JavaType]) => T, lifetime: InstanceScope = Transient): this.type = { - addToRegistry(new Registration[T](mirror.runtimeClass(typeOf[T]), this, factory, lifetime)) + addToRegistry(new Registration[T](mirror.runtimeClass(mirror.typeOf[T]), this, factory, lifetime)) } override def createScope(): Container = { diff --git a/scala/revenj-core/src/main/scala/net/revenj/serialization/JacksonSerialization.scala b/scala/revenj-core/src/main/scala/net/revenj/serialization/JacksonSerialization.scala index 2f6e703e..83781cd0 100644 --- a/scala/revenj-core/src/main/scala/net/revenj/serialization/JacksonSerialization.scala +++ b/scala/revenj-core/src/main/scala/net/revenj/serialization/JacksonSerialization.scala @@ -45,9 +45,9 @@ class JacksonSerialization( } def serialize[T: TypeTag](value: T): Try[String] = { - Utils.findType(typeOf[T], mirror) match { + Utils.findType(mirror.typeOf[T], mirror) match { case Some(tpe) => serializeRuntime(value, tpe) - case _ => Failure(new IllegalArgumentException("Unable to find Java type for: " + typeOf[T])) + case _ => Failure(new IllegalArgumentException(s"Unable to find Java type for: ${mirror.typeOf[T]}")) } } @@ -87,9 +87,9 @@ class JacksonSerialization( } override def deserialize[T: TypeTag](input: String): Try[T] = { - Utils.findType(typeOf[T], mirror) match { + Utils.findType(mirror.typeOf[T], mirror) match { case Some(tpe) => deserializeRuntime[T](input, tpe) - case _ => Failure(new IllegalArgumentException("Unable to find Java type for: " + typeOf[T])) + case _ => Failure(new IllegalArgumentException(s"Unable to find Java type for: ${mirror.typeOf[T]}")) } } }