The Scala 2.10 release notes says this: "Akka Actors now part of the distribution. The original Scala actors are now deprecated."
The latest Akka library ("Akka 2.1.0 for Scala 2.10") mentions the following dependency:
com.typesafe.akka:akka-actor_2.10:2.1.0
and the following examples:
import akka.actor.Actor
class MyActor extends Actor {..}
val system = ActorSystem("MySystem")
My project includes these libraries:
org.scala-lang:scala-library:2.10.0
org.scala-lang:scala-actors:2.10.0
In my classpath, I have no package called "akka". I do see instead scala.actors, but it doesn't seem deprecated.
So, in which way are Akka Actors "part of the distribution"?
If this is, indeed, the case, then am I still supposed to add the "akka-actor_2.10" library as a dependency? If so, do I use akka.Actor or the non-deprecated scala.actors.Actor ?
In scala 2.9.2 scala actors was part of scala-library.jar.
If you download a scala-2.10.0 distribution it there are no actors in scala-library and both akka-actors.jar and scala-actors.jar are supplied.
The latter is present for backwards compatibility and will be removed in a future major release.
akka-actors is the replacement and what you should use for any new development (and look to move anything using scala-actors across when possible).
If you have no current code in your project using actors you should probably reconfigure your project's dependencies to remove org.scala-lang:scala-actors:2.10.0 and instead depend on com.typesafe.akka:akka-actors_2.10:2.1.0 if you want to use actors.
I am not sure why there's no deprecation annotation on the classes in scala-actors in 2.10.0 but I believe it's to be added in 2.10.1.
You can find more info on the migration guide.
Related
I would like to cross-build some of my Bazel targets to Scala 2.12 and 2.13. As a further point of complexity, I need to be able to express cross-target dependencies (eg. some 2.13 target may have a Bazel dependency on a 2.12 target).
Note: this isn't a regular library dependency (eg. with the dependency 2.12-built JAR showing up on the class path when compiling the 2.13 JAR), as that would almost surely result in issues due to having two incompatible versions of the Scala standard library on the class path. Rather, this is just a case where I need the dependency JAR built so I can use it in some integration tests in the 2.13 target.
What I've found online so far...
This issue from rules_scala seems it doesn't support baking the Scala version into the target and instead you have to pick the Scala version globally.
This Databricks post has a cross-building section that is exactly what I think I would like (eg. one target generated per library per supported Scala version), but the snippets in that post don't seem to be backed by any runnable Bazel code.
This later post by Databricks also hints at a cross_scala_lib rule, but also doesn't have any accompanying code.
I have upgraded to reactive mongo 0.17.1 to 0.20.3. and after that I facing these warnings.
[WARN] [03/17/2020 12:20:43.782] [main]
[ManifestInfo(akka://reactivemongo)] Detected possible incompatible
versions on the classpath. Please note that a given Akka version MUST
be the same across all modules of Akka that you are using, e.g. if you
use [2.5.25] all other modules that are released together MUST be of
the same version. Make sure you're using a compatible set of
libraries. Possibly conflicting versions [2.5.25, 2.5.11] in libraries
[akka-protobuf:2.5.25, akka-actor:2.5.25, akka-slf4j:2.5.11,
akka-stream:2.5.25]
The reason for the error is that it is not safe to mix different patch versions of Akka modules, they all need to be of the same version (you can read more about this in the docs here.
Most often you can just add explicit dependencies in your build for the transitive ones to force them to be of the Akka version you want (2.5.25 in this case).
I am trying to compile code sample from this book (Play Framework Cookbook 2nd Edition) for JWT with nimbus-jose-jwt.
However it said Plugin trait type not found during compilation. I checked API documentation, Plugin is available at play.api package.
import play.api.{Logger, Play, Application, Plugin}
class JWTPlugin #Inject() (app: Application) extends Plugin {...}
I tried DI version with and without
routesGenerator := InjectedRoutesGenerator at build.sbt with same error.
nimbus-jose-jwt version: 3.8.2. Tried with latest 4.22, with same error.
scala: 2.11.8
play: 2.5.4
Appreciate any pointer. Thanks.
play.api.Plugin has been removed in Play 2.5.x. You can turn the plugin into a Module instead as described here: https://www.playframework.com/documentation/2.5.x/PluginsToModules
But the easiest solution is to turn the JWTPlugin class into a plain Scala object (e.g. JWTUtil), remove the onStart and onStop methods, remove the "private val jwt" declarations/assigments from all files in the example and call the sign() and verify() methods on the JWTUtil object instead.
Maybe you need some more minor modifications that I have forgotten, but anyway, the example works for me when the JWT implementation doesn't inherit from play.api.Plugin.
I am new to Scala.
I have downloaded the Scala Eclipse IDE, and started to write a new program using akka and actors, and I am trying to import akka as follows,
import akka.actor._
but am getting the errors as follows,
Multiple markers at this line
- not found: object akka
- object actor is not a member of
package akka
I want to know why I am getting this error, do I need to add any other packages ?
You need to add a dependency to the akka-actor jar. "Getting started" section of the Akka documentation http://doc.akka.io/docs/akka/snapshot/intro/getting-started.html has more information on which jars to add.
I've got a Scala project that is built with Gradle. The Scala code is source compatible with scala 2.9 and 2.10 and I'd like to cross build it to both major Scala versions. Does Gradle support this?
For example, my gradle project will have a single module:
build.gradle
src/main/scala/foo.scala
and I'd like the resulting published jars to be:
org-foo_2.9-0.1.jar (with dependency on scala-library 2.9)
org-foo_2.10-0.1.jar (with dependency on scala-library 2.10)
Gradle's Scala plugin doesn't currently support cross-building. It's possible to implement it yourself, though. In my Polyglot Gradle talk, I presented a proof-of-concept.
I am searching for a good example of this. The Gradle manual doesn't mention how to specify Scala version but looking at the source code for the Scala plugin it seems to infer it from the Scala library jar that you specify.
The best example I could find is the Apache Kafka build system. It specifies the Scala version and then uses some additional logic to resolve the correct version of the Scala libraries. It also uses some logic to attach the correct label to the jars its builds to correspond to the correct Scala version.
This feels like a lot of work and something that the build system should do for you like in SBT.