Skip to content

refactor: convert org.apache.pekko.X imports to pekko.X style#3348

Open
He-Pin wants to merge 5 commits into
mainfrom
refactor/pekko-style-imports
Open

refactor: convert org.apache.pekko.X imports to pekko.X style#3348
He-Pin wants to merge 5 commits into
mainfrom
refactor/pekko-style-imports

Conversation

@He-Pin

@He-Pin He-Pin commented Jul 14, 2026

Copy link
Copy Markdown
Member

Motivation

The Pekko codebase uses two import styles: import org.apache.pekko.X for the bare package import and import pekko.X for the shorter form. However, many files still use the fully qualified import org.apache.pekko.X.Y.Z style for individual imports instead of the shorter import pekko.X.Y.Z style.

Modification

A one-time transformation was applied across all 411 Scala source files:

  • import org.apache.pekko.X.Y.Zimport pekko.X.Y.Z
  • import org.apache.pekko is 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:

  1. Replaces org.apache.pekko. prefix with pekko. in import statements
  2. Adds import org.apache.pekko after the package declaration for files that need it
  3. Preserves grouped imports (import org.apache.pekko.actor.{ A, B }import pekko.actor.{ A, B })
  4. Preserves wildcard imports (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.X import style consistently. The import org.apache.pekko bare import is present in all files that use pekko.* imports.

Tests

Not run - import refactoring only, no behavioral changes.

References

None - import style improvement

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.
@He-Pin He-Pin force-pushed the refactor/pekko-style-imports branch from fc019a2 to 3b0664a Compare July 15, 2026 03:38
He-Pin added 3 commits July 15, 2026 12:13
…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.
@He-Pin He-Pin requested a review from pjfanning July 15, 2026 06:51
@He-Pin He-Pin added this to the 2.0.0-M4 milestone Jul 15, 2026
@He-Pin He-Pin removed the request for review from pjfanning July 15, 2026 08:48
@He-Pin He-Pin marked this pull request as draft July 15, 2026 08:48
@He-Pin He-Pin removed this from the 2.0.0-M4 milestone Jul 15, 2026
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
@He-Pin He-Pin marked this pull request as ready for review July 15, 2026 12:50
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

Successfully merging this pull request may close these issues.

2 participants