spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Maven plugin doesn't respect sourceDirectory/testSourceDirectory configurations

Open megfigura opened this issue 3 years ago • 0 comments

One of our projects uses a non-standard directory structure: src/com/... instead of src/main/java/com/... Maven has a sourceDirectory and testSourceDirectory configuration to support this. For example:

...
<build>
  <sourceDirectory>src</sourceDirectory>
  <testSourceDirectory>test</testSourceDirectory>
  <plugins>
...

Unfortunately, the Spotless Maven plugin hard-codes the standard paths here: com.diffplug.spotless.maven.java.Java#DEFAULT_INCLUDES. Because of that, it doesn't find any files to analyze in this project. As a workaround, the paths can be configured through <includes>, but it really should pick it up from the standard Maven configuration parameters.

Work-around:

...
<java>
  <includes>
    <include>src/**/*.java</include>
    <include>test/**/*.java</include>
  </includes>
...

Honestly, I'm fine with this getting closed as a won't-fix as it's unusual and has a workaround. Just wanted to add some key-words to the bug database because I would have found the solution quicker if this bug report existed :)

megfigura avatar May 17 '22 21:05 megfigura