spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Register dependencies task produces output outside of the configured build directory

Open netvl opened this issue 2 years ago • 1 comments

This issue is about the Gradle plugin.

When a project’s build directory is modified by a plugin, then, depending on the order of plugins application, the Spotless plugin may create the spotless-register-dependencies file in a wrong location.

This most likely happens because the register dependencies task’s output file property is not lazy, and therefore is configured/resolved to its final value during the configuration phase, when the plugin is applied, which introduces a dependency on the order of plugins application — if the plugin which configures the build directory is applied later than Spotless, then Spotless will use incorrect value of the build directory.

As a general rule, in Gradle it is recommended to use lazy properties for all kinds of properties which are exposed on tasks and extensions, especially input/output files or directories, and providers returning files/directories are usually obtained from project.layout.

  • Gradle version: 7.4.2
  • Spotless plugin version: 6.4.2

netvl avatar Apr 19 '22 23:04 netvl

Happy to merge a PR that fixes this, but it won't make the top of my todo list.

nedtwigg avatar Apr 22 '22 14:04 nedtwigg