diffplug / diffplug/spotless

Register dependencies task produces output outside of the configured build directory

Open
#1,173 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
Java
Stars
5.6k
Forks
559
Avg merge
1d 13h
Merged PRs (30d)
34

Description

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](https://github.com/diffplug/spotless/blob/4600bc36f7f23522037b3febf6a98ba6131cfbed/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/RegisterDependenciesTask.java#L78-L83) 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](https://docs.gradle.org/current/userguide/lazy_configuration.html) 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.