Skip to content
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

Better error message if you try to format a file outside the project directory. #588

Merged
merged 2 commits into from
May 31, 2020

Conversation

nedtwigg
Copy link
Member

Previously, it was possible to format files which were outside of the project directory. That was probably always a bug, but it turns out that users were "using" that feature. With the improved approach of 4.0, it is no longer possible to do that, which is probably good. But prior to this PR, spotless would still try to, which would lead to an error message like this:

Execution failed for task ':vividus:spotlessMisc'.
> Illegal char <:> at index 59: D:\a\vividus\vividus\vividus\output\spotless\spotlessMisc\D:\a\vividus\vividus\build.gradle

After this PR, that error message is changed to this:

> Spotless error! All target files must be within the project root. In project :vividus
    root dir: D:\a\vividus\vividus
      target: D:\a\vividus\build.gradle

It is good that 4.0 disallows this. For example, in the vividus example project above, spotless runs very slowly because every project is accidentally formatting all of the gradle files of every single other project. Before 4.x, Spotless chugged slowly along but eventually completed. After 4.x, it now errors clearly, and fixing the error will provide far better performance.

@bigdaz just FYI.

nedtwigg added 2 commits May 30, 2020 15:11
…re outside of the project directory, but we try anyway which creates a strange error message. We now give a much better error message.
@nedtwigg nedtwigg merged commit cee4960 into master May 31, 2020
@nedtwigg nedtwigg deleted the feat/outside-project-dir branch May 31, 2020 04:06
@nedtwigg
Copy link
Member Author

nedtwigg commented Jun 1, 2020

Released in plugin-gradle 4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant