Skip to content

Performance issue using IntelliJ Community Edition with spotless-maven-plugin and IDEA formatterΒ #2545

@ozlmulg

Description

@ozlmulg

Hi Spotless team πŸ‘‹

Description:

First of all, thanks for adding support for the IntelliJ IDEA formatter in the Spotless Maven plugin β€” it's a great feature!

I'm currently testing this integration using spotless-maven-plugin version 2.45.0-SNAPSHOT and IntelliJ IDEA Community Edition (latest available version). I'm using 2.45.0-SNAPSHOT, built locally, since there hasn't been a stable release yet that includes IntelliJ (idea) support for Maven.

The formatter works as expected, but performance has become a concern. Specifically, during a spotless:check or spotless:apply, the plugin appears to launch a separate IDEA instance for each file, like:

Launching IDEA formatter for orig file ... with params: [idea, format, -s, ..., /tmp/spotlessXYZ123.java] and env: {IDEA_PROPERTIES=/.../idea.properties}

This results in very slow formatting, especially for projects with hundreds of .java files.

Here's my relevant Maven configuration:

        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <version>2.45.0-SNAPSHOT</version>
          <executions>
            <execution>
              <goals>
                <goal>check</goal>
                <goal>apply</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <java>
              <includes>
                <include>src/**/*.java</include>
              </includes>
              <idea>
                <codeStyleSettingsPath>
                  /Users/ozlemulag/Documents/codestyle_settings.xml
                </codeStyleSettingsPath>
                <withDefaults>false</withDefaults>
                <binaryPath>/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea</binaryPath>
              </idea>
            </java>
          </configuration>
        </plugin>

Additional Notes:
When I run the formatter directly using the IntelliJ format.sh script and pass multiple files at once, performance is much faster. For example:

find . -name "*.java" -print0 | xargs -0 /Applications/IntelliJ\ IDEA\ CE.app/Contents/bin/format.sh -s /Users/ozlemulag/Documents/codestyle_settings.xml

This approach completes quickly even on large projects.

Request:
Is there any possibility to improve performance in the plugin?
I’m not sure whether this is technically feasible due to how the formatter integration works, but just wanted to ask if this is something that could be optimized.

Thanks again for your great work and looking forward to hearing your thoughts!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions