Stop Reviewing Import Order: Commit Eclipse Project Formatter Settings
Keep Eclipse formatting out of pull requests by committing project-specific formatter and save-action settings to your repository.
15 Oct 2025, 00:32 UTC

Pull requests full of formatting noise
A one-line logic fix should not become a 40-line diff. Yet pull requests often swell because import blocks are reordered, braces move to new lines, and line wraps shift. Every developer’s Eclipse workspace applies a slightly different Java style, so the real defect hides in mechanical churn.
The useful takeaway is that Eclipse JDT can absorb most of that work if the project owns the settings instead of each developer’s workspace. Commit the formatter and save-action preferences, and the IDE enforces a shared style before code reaches review.
Keep settings in the repository, not the workspace
Eclipse stores Java preferences in workspace metadata by default. Project-specific settings override those defaults for a single codebase. When enabled, Eclipse writes the rules into the project’s .settings folder, typically org.eclipse.jdt.core.prefs. Committing that file means every checkout sees the same line width, indentation, brace placement, and import rules.
Do not commit .metadata or personal launch configurations. Commit only project-applicable preference files, and document the folder in your team’s onboarding notes.
Worked example: align one team on one profile
- Open the Java project in Eclipse.
- Open project properties, then Java Code Style > Formatter. Enable project-specific settings and choose or import a formatter profile. Set line width, indentation, brace placement, and import order to match the team’s agreed style.
- In the same properties dialog, open Java Editor > Save Actions. Enable “Format source” and “Organize imports.” Add “Remove unused imports” only if the team agrees.
- Apply and save.
Create a scratch file in the project, for example src/com/example/Messy.java, with intentionally bad formatting:
package com.example;
import java.util.List;
import java.util.ArrayList ;
public class Messy{
void method ( List <String> items ){
ArrayList<String> list =new ArrayList<>();
for(String item:items){list.add(item);}
}
}
Save the file. Eclipse should rewrite imports, spacing, and braces according to the committed profile. From the repository root, run:
git status
Expected result: only the project preference file under .settings/ and the formatted sample file appear as changed. If you see personal workspace metadata or unrelated build output, review your .gitignore before committing.
Risk: applying “Format source” to the entire codebase in one commit mixes style churn with history. Isolate a mass reformat in its own commit, coordinate with active branches, and prefer formatting only touched files during normal work.
Save actions are not enforcement
Save actions run only when a developer uses that Eclipse setup and saves in the expected way. A teammate using another IDE can still commit unformatted code. If formatting is a hard requirement, add a CI gate—Checkstyle, Spotless, or an Eclipse headless formatter run—that fails the build on violations.
Eclipse’s formatter is not identical to google-java-format or Spotless. Mixing tools without one canonical source creates formatting fights instead of consistency. Pick one authority for the project and document it.
Limitations and how to verify
Aggressive clean-up can rewrite generated code, Lombok-heavy classes, or unusual annotation layouts in ways that produce noisy diffs. Scope save actions to safe operations and exclude generated source folders where possible.
After enabling the settings, format a deliberately messy file and inspect the diff. Then run the project build and any CI style check to confirm local Eclipse behavior and automated enforcement agree. If they disagree, update the CI rule or the Eclipse profile, not both independently.
Rollback
Committing .settings/org.eclipse.jdt.core.prefs changes repository state. You can revert it with a normal Git revert, or remove the file and disable project-specific settings in Eclipse. Announce the change first so developers are not surprised by format-on-save.
Closing
Choose one style authority, commit Eclipse project settings, document the save-action shortcut, add a CI check, and measure success by fewer style-only review comments—not by which tool wins.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.