Skip to content

Add Scalafix OrganizeImports to the Scala sample builds - #206

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:build/scalafix-organize-imports
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:build/scalafix-organize-imports

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 12, 2026

Copy link
Copy Markdown
Member

Motivation

Bring the semantic OrganizeImports workflow from apache/pekko#3342 to the standalone samples.

Modification

  • Add sbt-scalafix 0.14.10, a self-contained .scalafix.conf, and sbt sortImports to all 14 builds containing Scala sources, including the two Java samples with Scala multi-JVM tests. Register Scalafix for all five MultiJvm configurations.
  • Preserve the Pekko import groups, grouped selectors, and relative imports while removing unused imports.
  • Enable unused-import diagnostics only when SemanticDB is enabled, using a small auto plugin in each independent build. Ordinary compilation is unchanged.
  • Remove the competing Scalafmt SortImports rewrite and document the command in each sample.
  • Normalize the FSM and cluster-java multi-JVM sample imports with the new command.

Result

Each applicable example supports organizing its Scala main/test/multi-JVM imports even when copied out of this repository. Java-only samples are unchanged.

Tests

  • FSM sample on Scala 3.3.7 / JDK 17: inspected ordinary compiler options, ran sortImports twice in one sbt session, scalafixAll --check OrganizeImports, and test successfully.
  • Cluster-java sample: inspect MultiJvm / scalafix, sortImports, and MultiJvm / scalafix --check OrganizeImports passed, including compilation and rewriting of the two Scala multi-JVM test sources. Multi-node tests were not executed.
  • A temporary fixture confirmed that an unused UUID import is removed while a used ListBuffer import is retained. The fixture was removed afterwards.
  • Verified that import diagnostics and SemanticDB flags are enabled for the command and do not accumulate across repeated runs.
  • Generated headers for new code files with headerCreateAll using the repository's existing header text.
  • git diff --check passed.
  • Other sample builds, the documentation generator, and native Scalafmt were not run. No external-service integration tests or CI runs were monitored.

References

Refs apache/pekko#3342.

Motivation:
Provide the same semantic import organization as the Pekko core build.

Modification:
Add self-contained Scalafix 0.14.10 configuration, session-enabled compiler diagnostics and sortImports commands to all 14 examples with Scala sources, including the five MultiJvm configurations. Remove the competing Scalafmt rewrite and document usage.

Result:
Copied examples can organize imports without repository-root tooling.

Tests:
- FSM sample: ordinary compiler options inspected; sortImports twice in one session; scalafixAll --check OrganizeImports; test passed.
- Temporary fixture: unused UUID import removed, used ListBuffer retained; fixture removed.
- headerCreateAll passed using isolated sbt-header tooling and the existing repository header template.
- git diff --check passed.
- Cluster-java sample: MultiJvm / scalafix inspection, sortImports, and MultiJvm / scalafix --check OrganizeImports passed (two Scala sources compiled and rewritten).
- Remaining sample builds, docs-gen and native scalafmt were not run.

References:
Refs apache/pekko#3342
@He-Pin
He-Pin force-pushed the build/scalafix-organize-imports branch from 1efd221 to bef67fa Compare November 12, 2026 17:19
He-Pin added a commit to He-Pin/pekko-samples that referenced this pull request Nov 12, 2026
Motivation:
Provide consistent, self-contained formatting across the independent sbt samples.

Modification:
Configure core Scalafmt and Javafmt versions and style, preserve Scala language modes, include MultiJvm sources, document commands, and apply formatter output.

Result:
All 17 sbt builds expose working formatting/check commands. Maven-only samples and runtime dependencies remain unchanged.

Tests:
All 17 applyCodeStyle/checkCodeStyle workflows passed on JDK 17. Cluster Java compile, MultiJvm compile and test passed. Representative Paradox generation passed with a process-local Java 17 compatibility flag. Snippet identities and normalized Java tokens checked; git diff --check passed. Other full test suites and CI were not run.

References:
Refs apache#206; core formatter configuration at 6049edf9.
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.

1 participant