GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add IntelliJ IDEA formatter by simschla · Pull Request #2535 · diffplug/spotless

Conversation

@simschla

@simschla simschla commented Jun 29, 2025

Copy link
Copy Markdown
Contributor

This PR is based on @IlyasYOY work in #2020 🙏

It adds IntelliJ IDEA as a formatter for both gradle- and maven-plugin.

The implementation uses IntelliJ IDEA's formatting cli behind the scenes as intended by IntelliJ IDEA.

To make sure the IntelliJ IDEA instance launched by spotless is not interfering with a already running instance, we specify separated paths for idea.config.path and idea.system.path using a custom idea.properties file (see com.diffplug.spotless.generic.IdeaStep.State#createIdeaPropertiesFile).

For development, I've introduced a way to override the idea binary in a testenv.properties file since I do not find it feasible to add IDEA to my path just for this case.

I've tried adding a CI-step to let IDEA-tests run in CI. This part is untested and I'll work on it when the implementation is deemed feasible.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

IlyasYOY, Pankraz76, and beatngu13 reacted with thumbs up emoji IlyasYOY, lfgcampos, and ragnaroh-nrk reacted with hooray emoji rdehuyss reacted with heart emoji sureshg and rdehuyss reacted with rocket emoji
All reactions
  • 👍 3 reactions
  • 🎉 3 reactions
  • ❤️ 1 reaction
  • 🚀 2 reactions
IlyasYOY and others added 30 commits January 11, 2024 18:04
@IlyasYOY
Basic IDEA usage locally.
6419de1
Thought of implementation plan, experimented with code dependencies using
tests.
@IlyasYOY
Parameterize IDEA usage.
b84d243
Added parameterized method to call idea formatter.
@IlyasYOY
Verify IDEA binary.
1d8d9b2
Used ForeignExe to check idea binary
@IlyasYOY
Merge branch 'main' of github.com:diffplug/spotless
9d09760
@IlyasYOY
Gradle IDEA integration.
affd905
IDEA running using gradle
@IlyasYOY
Maven IDEA integration.
effe2fc
IDEA running using maven
@IlyasYOY
Make IDEA tests special
8e30175
As described here:
diffplug#200 (comment)
@IlyasYOY
docs: CHANGES.md
1554dd6
@IlyasYOY
Config file for IDEA step
763eaac
This part is lacking tests due to unpredictable nature of IDEA
formatting. They may change configs thus breaking build.
@IlyasYOY
CI Fixes
fdb73b7
@IlyasYOY
Merge branch 'main' of github.com:diffplug/spotless
e58c9f8
@IlyasYOY
docs: fixed structure of CHANGES.md
c6c6cce
@IlyasYOY
Merge branch 'main' of github.com:diffplug/spotless
bf5918c
@IlyasYOY
Create State object
9123527
This object is now resides in IdeaStep
@IlyasYOY
Merge branch 'main' of github.com:diffplug/spotless
7d6eed4
@nedtwigg
Merge branch 'main' into main-IlyasYOY
e03e715
@nedtwigg
spotlessApply
a0bde46
@simschla
feat: add support for absolute binary path
1025821
@simschla
fix: don't interact with the file directly
dc3b568
@simschla
doc: add link to jetbrains documentation
a9320dd
@simschla
Merge branch 'main' of github.com:diffplug/spotless into feature/inte…
9568b51
…llij-formatter

# Conflicts:
#	CHANGES.md
#	plugin-gradle/CHANGES.md
#	plugin-maven/CHANGES.md
@simschla
Merge remote-tracking branch 'upstream/main' into feature/intellij-fo…
c067d28
…rmatter
@simschla
refactor: move idea to generic formatters
39d1653
as it can handle various file formats besides java.
@simschla
refactor: use builder for idea-step creation
599ad51
@simschla
chore: provide custom idea.properties with custom config/system paths
d771a9c
@simschla
chore: fix formatter to use UTF-8 (as asserted by spotless)
619051c
@simschla
feat: allow specifying idea execs not on path
0570c6a
@simschla
refactor: turn ideastep into autoclosable implementation
1027aca
@simschla
refactor: adapt creation pipeline to allow createLazy to work with fu…
7b2b21c
…nction pointers
@simschla
chore: add testIdea to ci
412430d
simschla added 7 commits June 25, 2025 20:32
@simschla
docs: start documenting idea usage
b686a1c
@simschla
chore: adapt api for idea step
3277660
@simschla
docs: add documentation for IntelliJ codestyle
6d71e4d
@simschla
fix(mvn): pass developer root dir to maven tests
50e2589
@simschla
style: reformat with spotless
3000ad8
@simschla
docs: update with PR-reference
b7aed37
@simschla
fix: correct pmd warnings
b5e117e
@simschla
simschla requested a review from Copilot June 30, 2025 14:15
Copilot AI reviewed Jun 30, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces support for using IntelliJ IDEA’s command-line formatter in Spotless, including both Maven and Gradle plugins, test harness enhancements, and CI integration.

  • Add IdeaStep implementation and test environment overrides for custom IDEA binary and code style settings.
  • Integrate IDEA formatter into Maven (<idea>) and Gradle (idea()) DSLs, plus documentation and changelogs.
  • Enhance test infrastructure (@IdeaTest, TestEnvVars, CI matrix) to run IDEA-based formatting tests.

Reviewed Changes

Copilot reviewed 24 out of 26 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
testlib/src/test/java/com/diffplug/spotless/generic/IdeaStepTest.java Adds unit tests for IdeaStep behavior
testlib/src/main/resources/java/idea/full.dirty.java Dirty Java sample for IDEA formatting tests
testlib/src/main/resources/java/idea/full.clean.java Clean Java sample for IDEA formatting tests
testlib/src/main/java/com/diffplug/spotless/tag/IdeaTest.java Introduces @IdeaTest JUnit tag
testlib/src/main/java/com/diffplug/spotless/ResourceHarness.java Adds hasDifferentContent / notSameAsResource helpers
plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/IdeaTest.java Maven integration test for IDEA formatter
plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenRunner.java Extend MavenRunner to propagate system properties
plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationHarness.java Propagate spotless* properties into Maven test runs
plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Idea.java Implements Maven FormatterStepFactory for IDEA
plugin-maven/src/main/java/com/diffplug/spotless/maven/FormatterFactory.java Registers IDEA step in Maven formatter factory
plugin-maven/build.gradle Pass spotlessProjectDir system property for IDEA tests
plugin-maven/README.md Document IDEA support in Maven plugin
plugin-maven/CHANGES.md Changelog entry for new IDEA support
plugin-gradle/src/test/java/com/diffplug/gradle/spotless/JavaIdeaTest.java Gradle integration test for IDEA formatter
plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JavaExtension.java Minor comment fix
plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java Adds idea() DSL and IdeaConfig for IDEA formatting
plugin-gradle/README.md Document IDEA support in Gradle plugin
plugin-gradle/CHANGES.md Changelog entry for new IDEA support
lib/src/main/java/com/diffplug/spotless/generic/TestEnvVars.java Implements loading of testenv.properties for overrides
lib/src/main/java/com/diffplug/spotless/generic/IdeaStep.java Core implementation of the IDEA formatting step
gradle/special-tests.gradle Include idea in special test suite
INTELLIJ_IDEA_SCREENSHOTS.md Add docs for extracting IDEA code style settings
.github/workflows/ci.yml Add CI matrix entry and steps to run IDEA-based tests
Comments suppressed due to low confidence (3)

plugin-maven/README.md:41

  • [nitpick] Remove the stray // TODO add idea comment in the Languages section header; the documentation already includes IDEA, so clean up the header to avoid confusion.
- **Languages** // TODO add idea

testlib/src/test/java/com/diffplug/spotless/generic/IdeaStepTest.java:82

  • [nitpick] The test method name formattingsWithOutDefaultDoesNothing has inconsistent casing and a typo (WithOut); consider renaming it to formattingWithoutDefaultsDoesNothing for clarity.
	void formattingsWithOutDefaultDoesNothing() throws Exception {

testlib/src/test/java/com/diffplug/spotless/generic/IdeaStepTest.java:115

  • [nitpick] Consider adding tests for custom binaryPath and codeStyleSettingsPath builder options to verify that overrides are applied correctly.
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread plugin-maven/README.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

simschla added 2 commits June 30, 2025 16:25
@simschla
docs: fix typo
044f98d
@simschla
chore: cleanups based on review
6c7ecf5
@Pankraz76

Pankraz76 commented Jul 1, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

amazing feat thanks.

  • How will it effect the code later on?
    • Can we apply specific inspections as well?
    • Or does it just apply the default format settings imposed by idea?
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@simschla

simschla commented Jul 1, 2025

Copy link
Copy Markdown
Contributor Author

amazing feat thanks.

  • How will it effect the code later on?

    • Can we apply specific inspections as well?
    • Or does it just apply the default format settings imposed by idea?
image

The implementation uses IntelliJ's command line interface for formatting. So no, there is no support for inspections atm.

Pankraz76 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nedtwigg
nedtwigg approved these changes Jul 1, 2025
View reviewed changes

@nedtwigg nedtwigg left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Amazing! This LGTM. If you're happy with it too then press merge and I'll cut a release this week.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@simschla

simschla commented Jul 2, 2025

Copy link
Copy Markdown
Contributor Author

Awesome! I'll go ahead and merge it then 😄

nedtwigg reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@simschla
simschla merged commit 626a3d1 into diffplug:main Jul 2, 2025
@simschla
simschla deleted the feature/intellij-formatter branch July 2, 2025 12:39
@simschla simschla mentioned this pull request Jul 2, 2025
IDEA-180965: Add support for IntelliJ formatter #200
Closed
@nedtwigg

nedtwigg commented Jul 7, 2025

Copy link
Copy Markdown
Member

Released in plugin-gradle 7.1.0 and plugin-maven 2.45.0.

rdehuyss reacted with heart emoji lfgcampos and rdehuyss reacted with rocket emoji
All reactions
  • ❤️ 1 reaction
  • 🚀 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@nedtwigg nedtwigg nedtwigg approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@simschla @Pankraz76 @nedtwigg @IlyasYOY
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.