Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven scanning time issue for big projects #729

Closed
barmakoWS opened this issue Nov 10, 2020 · 5 comments · Fixed by #736
Closed

Maven scanning time issue for big projects #729

barmakoWS opened this issue Nov 10, 2020 · 5 comments · Fixed by #736

Comments

@barmakoWS
Copy link
Contributor

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:

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:

  1. Use another library to scan the baseDir
  2. 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.

@nedtwigg
Copy link
Member

That seems like a fine workaround to me. If you make the PR, I'd be happy to merge it and publish. We'll note the change in the changelog, and worst-case we can always revert it.

Our maven build is a bit tricky. Sounds like you already navigated it, but while you're in the guts of it, #554 is an option too.

@barmakoWS
Copy link
Contributor Author

Thanks for your response and sorry for my late reply.
Great, I'll try to open a PR soon with that fix.

@nedtwigg
Copy link
Member

Possibly fixed in plugin-maven 2.6.1. Please test and confirm.

@nedtwigg nedtwigg reopened this Nov 16, 2020
@barmakoWS
Copy link
Contributor Author

It solves my issue.
Thanks for the help!

@nedtwigg
Copy link
Member

Huzzah!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants