-
Notifications
You must be signed in to change notification settings - Fork 6
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
Running spotless seems to do a full build #75
Comments
It is a full build in that One speedup you could try for multi-module projects is:
By specifying that you only want to run the subproject spotlessApply and its parent(s), this allows Gradle to skip configuration of every other subproject. Another avenue of speed up is the new "configuration cache" introduced in |
I think we (spotless) can make the root |
Thanks for the info! (And sorry for the delayed response.) I'm going to do some digging to spot any optimisations. The "full build" part could potentially be an issue with the vscode gradle tasks extension, which i need to investigate, but I'll also have a look at your suggested approach for spotless optimisations as I am curious. |
With a multi-project build, running the root task:
Shows these logs:
With a multi-project build, running the sub-project task and the root task:
Shows these logs:
With a multi-project build, running just the sub-project task:
Shows these logs:
Running just the sub-project task without the root task seems to be the most efficient. I haven't been able to do a performance check of this change due to all the gradle caching but I assume it's going to give some gains. I can try test on a slow windows VM. Regarding the "Configure Project" logs, these are emitted no matter which task I execute, and I don't really know what they mean and assume it's just internal to gradle. (These logs are emitted via the Gradle Tooling API.) I'm not sure there's anything I can optimise there. @nedtwigg i'll watch diffplug/spotless#623 but also happy to make this change in the extension too. It can be an optimisation for users who haven't upgraded their spotless version. What do you think? |
This is expected, but it could trigger a bug. The bug is this: // root build.gradle
target '*.gradle', '*/*.gradle' // format the root gradle scripts, and the gradle scripts of all subprojects The target above is a bad idea, but it's out there. Spotless allows you to format any file "below" you, so if a file is in the
If you set
This is a great idea. First off, you are 100% correct that it will be a speedup for all versions of Spotless that support the IDE hook. I'd say you don't even need to follow 623 anymore, because I don't think it can go any faster than you can. It would be the same speed, just less work for you to integrate. But if you've already done the integration work, why add more to detect "such and such version", since there's no benefit. I also don't have any plans to implement 623 anytime soon. |
Thanks for the clarifications! Cool, I'll have a bash an implementing the change in this extension 👍 Regarding the logic to detect which (sub)project a file belongs to, it looks like this might be a bit tricky, as you can rename the build file to something other than the standard convention ( It seems the best way to do this is to use the Gradle API to figure this out. Example here. AFAIK, the Gradle Tooling API doesn't expose similar API methods, and I'd need to add a custom plugin/model to the build (via an init script) in order to query the build. I have a (very rough) POC for adding a custom plugin & model to the build, but I remember having issues by not being able to debug the plugin. Either way, I will need to do further investigations before deciding on the correct approach here. Sadly it doesn't seem straightforward. |
If the instructions to users for getting the speedup are "apply spotless, and then also apply this other plugin in your init.gradle", then I would think that it would be better to just get |
I really don't want to go the init script route, but as you point out it does open up the possibility for other features in the main vscode-gradle extension. At a very high-level, and without thinking about it too deeply, here's the concept:
But now that I type that out, i see that running that additional logic in gradle could result in a performance hit. So it's hard to say it's worth the effort. I am tempted to scratch that plan, and just do a simple directory traversal looking for common build files ( |
You'll need to also detect if they are using some non-standard layout, and bail out of only calling the subprojects, and instead call the full-blown I semi-frequently create multi-project setups where the only build.gradle is in the root project, and just IMO, this is shaping up to be complicated enough that |
I didn't know you could do this :(
Yea, with this new information it does seem like doing this with spotless would be easiest and best. I guess i'll just keep an eye out on diffplug/spotless#623. If i have time to get familiar with the spotless codebase i might try contribute. I might also try solve this "client side" as i am curious, but it's a chunk of work so i can't say when i can get around to trying it. |
This is evident on slow machines. When running spotless you see in the statusbar "Configure project" etc.
The text was updated successfully, but these errors were encountered: