Share source directory between Scala 2.13 and Scala 3 (#30384)
This commit is contained in:
parent
b65f02e6b4
commit
9b5aad942f
11 changed files with 10 additions and 133 deletions
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2009-2021 Lightbend Inc. <https://www.lightbend.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package akka.compat
|
|
||||||
|
|
||||||
import scala.collection.immutable
|
|
||||||
import scala.concurrent.{ ExecutionContext, Future => SFuture }
|
|
||||||
|
|
||||||
import akka.annotation.InternalApi
|
|
||||||
|
|
||||||
/**
|
|
||||||
* INTERNAL API
|
|
||||||
*
|
|
||||||
* Compatibility wrapper for `scala.concurrent.Future` to be able to compile the same code
|
|
||||||
* against Scala 2.12, 2.13
|
|
||||||
*
|
|
||||||
* Remove these classes as soon as support for Scala 2.12 is dropped!
|
|
||||||
*/
|
|
||||||
@InternalApi private[akka] object Future {
|
|
||||||
def fold[T, R](futures: IterableOnce[SFuture[T]])(zero: R)(op: (R, T) => R)(
|
|
||||||
implicit executor: ExecutionContext): SFuture[R] = {
|
|
||||||
// This will have performance implications since the elements are copied to a Vector
|
|
||||||
SFuture.foldLeft[T, R](futures.iterator.to(immutable.Iterable))(zero)(op)(executor)
|
|
||||||
}
|
|
||||||
|
|
||||||
def fold[T, R](futures: immutable.Iterable[SFuture[T]])(zero: R)(op: (R, T) => R)(
|
|
||||||
implicit executor: ExecutionContext): SFuture[R] =
|
|
||||||
SFuture.foldLeft[T, R](futures)(zero)(op)(executor)
|
|
||||||
|
|
||||||
def reduce[T, R >: T](futures: IterableOnce[SFuture[T]])(op: (R, T) => R)(
|
|
||||||
implicit executor: ExecutionContext): SFuture[R] = {
|
|
||||||
// This will have performance implications since the elements are copied to a Vector
|
|
||||||
SFuture.reduceLeft[T, R](futures.iterator.to(immutable.Iterable))(op)(executor)
|
|
||||||
}
|
|
||||||
|
|
||||||
def reduce[T, R >: T](futures: immutable.Iterable[SFuture[T]])(op: (R, T) => R)(
|
|
||||||
implicit executor: ExecutionContext): SFuture[R] =
|
|
||||||
SFuture.reduceLeft[T, R](futures)(op)(executor)
|
|
||||||
|
|
||||||
def find[T](futures: IterableOnce[SFuture[T]])(p: T => Boolean)(
|
|
||||||
implicit executor: ExecutionContext): SFuture[Option[T]] = {
|
|
||||||
// This will have performance implications since the elements are copied to a Vector
|
|
||||||
SFuture.find[T](futures.iterator.to(immutable.Iterable))(p)(executor)
|
|
||||||
}
|
|
||||||
|
|
||||||
def find[T](futures: immutable.Iterable[SFuture[T]])(p: T => Boolean)(
|
|
||||||
implicit executor: ExecutionContext): SFuture[Option[T]] =
|
|
||||||
SFuture.find[T](futures)(p)(executor)
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2009-2021 Lightbend Inc. <https://www.lightbend.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package akka.compat
|
|
||||||
|
|
||||||
import akka.annotation.InternalApi
|
|
||||||
|
|
||||||
/**
|
|
||||||
* INTERNAL API
|
|
||||||
*
|
|
||||||
* Compatibility wrapper for `scala.PartialFunction` to be able to compile the same code
|
|
||||||
* against Scala 2.12, 2.13, 3.0
|
|
||||||
*
|
|
||||||
* Remove these classes as soon as support for Scala 2.12 is dropped!
|
|
||||||
*/
|
|
||||||
@InternalApi private[akka] object PartialFunction {
|
|
||||||
|
|
||||||
def fromFunction[A, B](f: (A) => B): scala.PartialFunction[A, B] = {
|
|
||||||
scala.PartialFunction.fromFunction(f)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2009-2021 Lightbend Inc. <https://www.lightbend.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package akka.dispatch.internal
|
|
||||||
|
|
||||||
import scala.concurrent.ExecutionContext
|
|
||||||
|
|
||||||
import akka.annotation.InternalApi
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory to create same thread ec. Not intended to be called from any other site than to create [[akka.dispatch.ExecutionContexts#parasitic]]
|
|
||||||
*
|
|
||||||
* INTERNAL API
|
|
||||||
*/
|
|
||||||
@InternalApi
|
|
||||||
private[dispatch] object SameThreadExecutionContext {
|
|
||||||
def apply(): ExecutionContext = ExecutionContext.parasitic
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2019-2021 Lightbend Inc. <https://www.lightbend.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package akka.util.ccompat
|
|
||||||
|
|
||||||
import scala.annotation.Annotation
|
|
||||||
|
|
||||||
import akka.annotation.InternalApi
|
|
||||||
|
|
||||||
/**
|
|
||||||
* INTERNAL API
|
|
||||||
*
|
|
||||||
* Annotation to mark files that need ccompat to be imported for Scala 2.11 and/or 2.12,
|
|
||||||
* but not 2.13. Gets rid of the 'unused import' warning on 2.13.
|
|
||||||
*/
|
|
||||||
@InternalApi
|
|
||||||
private[akka] class ccompatUsedUntil213 extends Annotation
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2018-2021 Lightbend Inc. <https://www.lightbend.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
package akka.util
|
|
||||||
|
|
||||||
/**
|
|
||||||
* INTERNAL API
|
|
||||||
*
|
|
||||||
* Based on https://github.com/scala/scala-collection-compat/blob/master/compat/src/main/scala-2.13/scala/collection/compat/package.scala
|
|
||||||
* but reproduced here so we don't need to add a dependency on this library. It contains much more than we need right now, and is
|
|
||||||
* not promising binary compatibility yet at the time of writing.
|
|
||||||
*/
|
|
||||||
package object ccompat {
|
|
||||||
private[akka] type Factory[-A, +C] = scala.collection.Factory[A, C]
|
|
||||||
private[akka] val Factory = scala.collection.Factory
|
|
||||||
|
|
||||||
// When we drop support for 2.12 we can delete this concept
|
|
||||||
// and import scala.jdk.CollectionConverters.Ops._ instead
|
|
||||||
object JavaConverters
|
|
||||||
extends scala.collection.convert.AsJavaExtensions
|
|
||||||
with scala.collection.convert.AsScalaExtensions
|
|
||||||
}
|
|
||||||
|
|
@ -130,6 +130,16 @@ object AkkaBuild {
|
||||||
Compile / javacOptions ++= (if (allWarnings) Seq("-Xlint:deprecation") else Nil),
|
Compile / javacOptions ++= (if (allWarnings) Seq("-Xlint:deprecation") else Nil),
|
||||||
doc / javacOptions := Seq(),
|
doc / javacOptions := Seq(),
|
||||||
crossVersion := CrossVersion.binary,
|
crossVersion := CrossVersion.binary,
|
||||||
|
// Adds a `src/main/scala-2.13+` source directory for code shared
|
||||||
|
// between Scala 2.13 and Scala 3
|
||||||
|
unmanagedSourceDirectories in Compile ++= {
|
||||||
|
val sourceDir = (sourceDirectory in Compile).value
|
||||||
|
CrossVersion.partialVersion(scalaVersion.value) match {
|
||||||
|
case Some((3, n)) => Seq(sourceDir / "scala-2.13+")
|
||||||
|
case Some((2, n)) if n >= 13 => Seq(sourceDir / "scala-2.13+")
|
||||||
|
case _ => Nil
|
||||||
|
}
|
||||||
|
},
|
||||||
ThisBuild / ivyLoggingLevel := UpdateLogging.Quiet,
|
ThisBuild / ivyLoggingLevel := UpdateLogging.Quiet,
|
||||||
licenses := Seq(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html"))),
|
licenses := Seq(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html"))),
|
||||||
homepage := Some(url("https://akka.io/")),
|
homepage := Some(url("https://akka.io/")),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue