-
Notifications
You must be signed in to change notification settings - Fork 497
Description
Hi,
I have a project that has a directory with an insane amount of code that I don't want spotless to consider (the code inside this directory is used as an input for some tests).
I'm providing spotless with an include/exclude configuration that should skip said directory.
Spotless takes over 90 seconds to complete.
I looked at the code for the maven plugin and it seems that the files spotless works on are computed by a 3rd party as follows:
spotless/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java
Lines 204 to 210 in 48b5cb9
| private List<File> collectFilesFromFormatterFactory(FormatterFactory formatterFactory) | |
| throws MojoExecutionException, IOException { | |
| String includesString = String.join(",", getIncludes(formatterFactory)); | |
| String excludesString = String.join(",", getExcludes(formatterFactory)); | |
| return FileUtils.getFiles(baseDir, includesString, excludesString); | |
| } |
FileUtils.getFiles is provided by org.codehaus.plexus:plexus-utils:3.0.8 which is a transitive dependency of org.codehaus.plexus:plexus-resources:1.0.1
I've checked to see if the problem comes from the plexus-utils, and indeed the folder scan is slow (probably doesn't skip entire directories).
This issue was fixed in a later version of plexus-utils and I verified that it works much faster when using its latest version - 3.3.0
The direct dependency spotless uses (org.codehaus.plexus:plexus-resources:1.0.1) has a newer version (1.1.0) that uses org.codehaus.plexus:plexus-utils:3.0.22 - but it doesn't fix the issue.
I can suggest the following solutions:
- Use another library to scan the
baseDir - Override the used version of org.codehaus.plexus:plexus-utils to 3.3.0 - this is, of course, risky, as plexus-resources wasn't "compiled" against it
What are your thoughts?
I'd be happy to help with a PR if needed.