Right now, the IDE hook works like this
spotlessApply -PspotlessIdeHook=${ABSOLUTE_PATH_TO_FILE}
But for large multiproject projects we could make it significantly faster with (note the leading colon)
:spotlessApply -PspotlessIdeHook=${ABSOLUTE_PATH_TO_FILE} --configure-on-demand
but only if we modified this code
| @Override |
| protectedvoidcreateFormatTasks(Stringname, FormatExtensionformatExtension) { |
| booleanisIdeHook = project.hasProperty(IdeHook.PROPERTY); |
by adding something like:
if (project == rootProject) {
StringideHookPath = (String) project.property(IdeHook.PROPERTY);
project.gradle.settingsEvaluated { settings -> // the code below works only for root with children, needs to also handle children with childrenProjectDescriptorowningProject = null;
ProjectDescriptorrootDescriptor = settings.rootProjectfor (ProjectDescriptorchild : rootDescriptor.children) {
if (ideHookPath.startsWith(child.projectDir.absolutePath)) {
owningProject = child;
} }
if (owningProject != null) {
project.evaluationDependsOn(owningProject.path)
}
}
}In this way we can avoid evaluating all the spotlessApply tasks and instead only evaluate the root project and, if necessary, the project which contains the file in question.
Right now, the IDE hook works like this
But for large multiproject projects we could make it significantly faster with (note the leading colon)
but only if we modified this code
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessExtensionImpl.java
Lines 54 to 56 in 48723eb
by adding something like:
In this way we can avoid evaluating all the
spotlessApplytasks and instead only evaluate the root project and, if necessary, the project which contains the file in question.