Skip to content

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

Merged
He-Pin merged 2 commits into
mainfrom
refactor/pekko-style-imports
Jul 18, 2026
Merged

refactor: convert org.apache.pekko.X imports to pekko.X style#3348
He-Pin merged 2 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

@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 a commit that referenced this pull request Jul 15, 2026
…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
@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
He-Pin added a commit that referenced this pull request 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
Comment thread actor-tests/src/test/scala/org/apache/pekko/actor/FSMTimingSpec.scala Outdated
@He-Pin He-Pin added this to the 2.0.0-M4 milestone Jul 17, 2026
He-Pin added a commit that referenced this pull request Jul 17, 2026
Motivation:
The Pekko codebase uses two import styles: `import org.apache.pekko.X.Y.Z`
for the bare package import and `import pekko.X.Y.Z` for the shorter form.
Many files still use the fully qualified style for individual imports.

Modification:
Convert `import org.apache.pekko.X.Y.Z` to `import pekko.X.Y.Z` across
all Scala source files by adding `import org.apache.pekko` as a bare
package import and using the `pekko.*` prefix for subsequent imports.
The bare `import org.apache.pekko` is placed immediately adjacent to the
`import pekko.*` imports with no blank lines separating them.

Result:
All Scala source files now use the shorter `pekko.X` import style
consistently, with the bare `import org.apache.pekko` grouped directly
with the pekko imports.

Tests:
- sbt +headerCheckAll -> success
- scalafmt --list --mode diff-ref=origin/main -> no output

References:
Refs #3348
@He-Pin
He-Pin force-pushed the refactor/pekko-style-imports branch from 2bd356e to 54c6002 Compare July 17, 2026 13:10
@He-Pin
He-Pin requested a review from pjfanning July 18, 2026 04:36
@He-Pin

He-Pin commented Jul 18, 2026

Copy link
Copy Markdown
Member Author

@pjfanning It's fixed now

@He-Pin
He-Pin requested a review from raboof July 18, 2026 04:36
import org.apache.pekko.stream.testkit.{ TestPublisher, TestSubscriber }
import org.apache.pekko.testkit.{ PekkoSpec, TestLatch }
import org.apache.pekko

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still quite a few gaps like this


package docs.stream

import org.apache.pekko

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep this with the pekko imports?

He-Pin added 2 commits July 18, 2026 22:15
Motivation:
The Pekko codebase uses two import styles: `import org.apache.pekko.X.Y.Z`
for the bare package import and `import pekko.X.Y.Z` for the shorter form.
Many files still use the fully qualified style for individual imports.

Modification:
Convert `import org.apache.pekko.X.Y.Z` to `import pekko.X.Y.Z` across
all Scala source files by adding `import org.apache.pekko` as a bare
package import and using the `pekko.*` prefix for subsequent imports.
The bare `import org.apache.pekko` is placed immediately adjacent to the
`import pekko.*` imports with no blank lines separating them.

Result:
All Scala source files now use the shorter `pekko.X` import style
consistently, with the bare `import org.apache.pekko` grouped directly
with the pekko imports.

Tests:
- sbt +headerCheckAll -> success
- scalafmt --list --mode diff-ref=origin/main -> no output

References:
Refs #3348
Motivation:
PR review feedback: import org.apache.pekko and import pekko.X should
be grouped together without blank lines or non-pekko imports separating
them.

Modification:
Remove blank lines between import org.apache.pekko and import pekko.X,
move non-pekko imports after the pekko import group with a blank line
separator.

Result:
All pekko imports are consistently grouped together across 82 files.

Tests:
- Not run - import ordering only

References:
Refs #3348
@He-Pin
He-Pin force-pushed the refactor/pekko-style-imports branch from 54c6002 to 436d0cf Compare July 18, 2026 14:29

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin
He-Pin merged commit 9dfca01 into main Jul 18, 2026
10 checks passed
@He-Pin
He-Pin deleted the refactor/pekko-style-imports branch July 18, 2026 20:20
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