spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Can Spotless be configured to use e.g. "GoogleJavaFormat 1.21.0 or newer"?

Open flpa opened this issue 10 months ago • 0 comments

Is it possible to use a "flexible" version for googleJavaFormat, e.g. to tell spotless "use version 1.21.0 or newer"?

Details:

We are currently using spotless like this in our builds:

 <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>2.43.0</version>
        <configuration>
          <java>
            <googleJavaFormat>
              <version>1.21.0</version>
              <style>GOOGLE</style>
            </googleJavaFormat>
          </java>
       ...
        </configuration>
      </plugin>

In IntelliJ IDEA, we are using the google-java-format plugin, so that the code style matches between IDE and build. However, IDE plugins offer updates rather often or install them automatically, so we are concerned that the version of GoogleJavaFormat could diverge between IDE and build in the future. We thought about configuring spotless to automatically pick the latest version of the format according to some version range notation, for example in NPM notation:

            <googleJavaFormat>
              <version>^1.21.0</version>
              <style>GOOGLE</style>
            </googleJavaFormat>

Or in oldschool Maven notation:

            <googleJavaFormat>
              <version>[1.21.0,)</version>
              <style>GOOGLE</style>
            </googleJavaFormat>

We couldn't find anything related in the spotless docs or issue tracker, so we just tried these two notations and they did not work. Is something like that supported, or a possible feature in the future?

flpa avatar Apr 04 '24 08:04 flpa