refactor: convert org.apache.pekko.X imports to pekko.X style#3348
Open
He-Pin wants to merge 5 commits into
Open
refactor: convert org.apache.pekko.X imports to pekko.X style#3348He-Pin wants to merge 5 commits into
He-Pin wants to merge 5 commits into
Conversation
pjfanning
reviewed
Jul 14, 2026
Convert all `import org.apache.pekko.X.Y.Z` imports to the shorter `import pekko.X.Y.Z` style by adding `import org.apache.pekko` as a bare package import and using the `pekko.*` prefix for subsequent imports within the same file. This affects 411 source files across the project, rewriting 885 individual import statements.
fc019a2 to
3b0664a
Compare
…d at file scope Motivation: The previous refactor commit (3b0664a) failed CI on four jobs: - Check headers (2 files had a leading blank line before the license header) - Code is formatted (docs module, same root cause) - Check / Code Style (scalafmt on docs module) - Check / Tests (next) - Scala 3 compile failed in actor-typed-tests and remote-tests because `import pekko.*` references at file scope were not preceded by the bare `import org.apache.pekko` that brings the short package name into scope. The script had added the bare import only inside nested object/class blocks, which is invisible at file scope under Scala 3's stricter import resolution. Modification: - Strip the leading blank line in docs/src/test/scala/docs/persistence/ PersistenceMultiDocSpec.scala and project/Paradox.scala so the license header starts on line 1 again. - Add a file-scope `import org.apache.pekko` immediately after the package declaration (or at the top of the file for header-less files) in every Scala file that uses `import pekko.*` at file scope without an existing bare import at file scope. Same-pattern search across the whole repository found 27 additional files beyond the 3 that Scala 3 flagged in CI; all are fixed to prevent the same failure under Scala 2 and to keep the two import styles consistent. - The nested `import org.apache.pekko` already present inside doc snippets (e.g. `object FaultToleranceDocSpec { ... }`) is preserved, since those blocks demonstrate the pattern inline. Result: - sbt +headerCheckAll passes. - sbt scalafmtCheckAll and scalafmtSbtCheck pass. - sbt ++ 3.3.7 actor-typed-tests / Test / compile and remote-tests / MultiJvm / compile both succeed. - scalafmt --list --mode diff-ref=origin/main reports no files needing formatting. - Change footprint: 30 files, +58/-2 (only the bare imports and two leading-blank-line removals; no unrelated formatting churn). Tests: - sbt +headerCheckAll -> success - sbt scalafmtCheckAll; scalafmtSbtCheck -> success - sbt ++ 3.3.7 actor-typed-tests / Test / compile -> success - sbt ++ 3.3.7 remote-tests / MultiJvm / compile -> success - scalafmt --list --mode diff-ref=origin/main -> no output References: Refs #3348
…import errors The previous commit added `import org.apache.pekko` inside nested scopes (package objects, snippet blocks) where the same import was already available from an outer scope. Scala 2.13 -Wunused:imports flagged these as fatal errors in CI.
The bare `import org.apache.pekko` must appear before any `import pekko.X` statements, otherwise Scala 3 fails with "Not found: pekko" since the alias is not yet defined at the point of use.
Motivation: The import refactoring introduced duplicate //#config and //#spec Paradox markers, causing the docs build to fail with "Label [config] block not closed" and "Label [spec] block not closed" errors. Modification: Remove the duplicate markers and place imports correctly within their respective Paradox snippet blocks. Result: Paradox doc build succeeds again. Tests: sbt docs/paradox (fixes the 2 Paradox errors from CI) References: Fixes CI failure in #3348
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The Pekko codebase uses two import styles:
import org.apache.pekko.Xfor the bare package import andimport pekko.Xfor the shorter form. However, many files still use the fully qualifiedimport org.apache.pekko.X.Y.Zstyle for individual imports instead of the shorterimport pekko.X.Y.Zstyle.Modification
A one-time transformation was applied across all 411 Scala source files:
import org.apache.pekko.X.Y.Z→import pekko.X.Y.Zimport org.apache.pekkois added as a bare package import at the top of each affected file (if not already present)This rewrites 885 individual import statements. Auto-generated files in
target/directories are excluded.The transformation was performed with a text-based script that:
org.apache.pekko.prefix withpekko.in import statementsimport org.apache.pekkoafter the package declaration for files that need itimport org.apache.pekko.actor.{ A, B }→import pekko.actor.{ A, B })import org.apache.pekko.actor._→import pekko.actor._)Scalafmt was run after the transformation to normalize formatting.
Result
All Scala source files now use the shorter
pekko.Ximport style consistently. Theimport org.apache.pekkobare import is present in all files that usepekko.*imports.Tests
Not run - import refactoring only, no behavioral changes.
References
None - import style improvement