palantir-java-format icon indicating copy to clipboard operation
palantir-java-format copied to clipboard

Unable to load class 'com.diffplug.spotless.FormatterStep'.

Open lackovic opened this issue 6 months ago • 1 comments

Followed these instructions in the README and when I sync Gradle changes in IntelliJ IDEA I get the following error:

Build file 'build.gradle' line: 42

A problem occurred evaluating root project.
> Failed to apply plugin class 'com.palantir.javaformat.gradle.PalantirJavaFormatSpotlessPlugin'.
   > Could not create an instance of type com.palantir.javaformat.gradle.SpotlessInterop.
      > Could not generate a decorated class for type SpotlessInterop.
         > com/diffplug/spotless/FormatterStep

Line 42 is the following:

    apply plugin: 'com.palantir.java-format'

I am getting the same error, regardless of whether the plugin is installed or not.

Using Gradle 8.14.3.

Any idea what I might be doing wrong?

lackovic avatar Jul 22 '25 07:07 lackovic

I was able to work around this by also including the spotless plugin.

Here's a simplified version of my multi module build.gradle:

plugins {
  id 'java'
  id 'java-library'
  id 'java-test-fixtures'
  id 'io.freefair.lombok' version '6.5.0.3'
  // Note that I didn't particularly mind whether we had spotless or not, but it's an implicit
  // dependency for the java-format plugin (it fails without spotless plugin being present, even
  // if it isn't applied
  id 'com.diffplug.spotless' version '7.2.1'
  id 'com.palantir.java-format' version '2.73.0'
}

repositories {
  mavenCentral()
}

With this in place I was able to successfully run format and formatDiff

nicobrevin avatar Aug 15 '25 21:08 nicobrevin