Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

follow up with maintainers of externally maintained alpakka connectors #23

Open
pjfanning opened this issue Jan 25, 2023 · 2 comments
Open

Comments

@pjfanning
Copy link
Contributor

  • see https://doc.akka.io/docs/alpakka/current/external/
  • 3 of those are Akka maintained and we have Pekko equivalents (gRPC, TCP, HTTP)
  • the others are not maintained by Lightbend and there is no Pekko team equivalent
  • we could raise issues with the lib owners when Pekko snapshots are ready
@jtjeferreira
Copy link
Contributor

I have used the following code to use source generators and search/replace on the imports to publish the same library for akka and pekko:

import sbt._

object PekkoMigration {
  def generatePekkoSourcesFromAkka(scalaSourceDirectory: File, sourceManagedDir: File): Seq[File] = {
    val scalaFiles: PathFinder = scalaSourceDirectory ** "*.scala"
    //collect the files
    val filesToBeCopied: Seq[(File, File)] = scalaFiles.get().map { f =>
      val Some(relative) = scalaSourceDirectory.relativize(f)
      val target: File = sourceManagedDir / relative.toPath.toString
      (f, target)
    }
    //copy the files
    val copiedFiles = IO.copy(filesToBeCopied).toSeq
    //rewrite imports
    copiedFiles.map { f =>
      val modifiedLines = IO.readLines(f).map {
        case l if l.startsWith("import akka.stream.alpakka") =>
          l.replaceFirst("import akka.stream.alpakka", "import org.apache.pekko.stream.connectors")
        case l if l.startsWith("import akka") =>
          l.replaceFirst("import akka", "import org.apache.pekko")
        case l => l
      }
      IO.writeLines(f, modifiedLines)
      f
    }
  }
}

and then you can use it like this

    Compile / sourceGenerators += Def.task {
      PekkoMigration.generatePekkoSourcesFromAkka((AKKA_PROJECT / Compile / scalaSource).value, (Compile / sourceManaged).value)
    }.taskValue

It is not very fancy (i.e it does not use scalafix) but gets the job done for small libs

@pjfanning
Copy link
Contributor Author

with the Kinesis alternatives, I've logged issues in those projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants