diffplug / diffplug/spotless

Register dependencies task produces output outside of the configured build directory

Aperta
#1,173 1 commento 1 reazione 0 assegnatari Vedi su GitHub
bug
Lingua principale
Java
Stelle
5.6k
Fork
559
Merge medio
1g 13h
PR unite (30g)
34

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.