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

Support up-to-date checking of format task #323

Closed

Conversation

larsgrefer
Copy link
Contributor

The format tasks are currently always out-of-date because the task did not declare its outputs.

This also adds the JavaFormatConfig options as inputs to the tasks, so both the format and check tasks will be out-of-date, when the configuration changes.

@wilkinsona
Copy link
Contributor

Thanks for the proposal, @larsgrefer. It was a conscious decision not to support up-to-date checks with the format task. The usage model that we had in mind (and that we use ourselves) is that the format checking is done as part of every build, but format is only ever run manually to fix a formatting problem. I'm guessing that you're using the plugin differently. What's the motivation for this change?

@larsgrefer
Copy link
Contributor Author

While working on the Spring Boot codebase I've used ./gradlew format to manually fix the formatting of the files I modified. I was a bit confused by the fact that the whole codebase would be reformatted every time even though I was only working on 2 or 3 files:

BUILD SUCCESSFUL in 13s
225 actionable tasks: 222 executed, 3 up-to-date

I would have expected that the format* tasks for the other modules should be up-to-date at some point.
So I checked why they were not up-to-date:

Task ':spring-boot-tests:spring-boot-smoke-tests:spring-boot-smoke-test-websocket-undertow:formatMain' is not up-to-date because:
  Task has not declared any outputs despite executing actions.

Correctly declaring the inputs and outputs of the tasks is an easy fix, so I opened this PR.

I agree that up-to-date checks aren't super important for the usage model you had in mind, but I don't see a reason to deliberately break them.

@wilkinsona wilkinsona changed the title Fix Gradles up-to-date checks by correctly declaing the task inputs and outputs Fix Gradles up-to-date checks by correctly declaring the task inputs and outputs May 24, 2022
@wilkinsona wilkinsona changed the title Fix Gradles up-to-date checks by correctly declaring the task inputs and outputs Support up-to-date checking of format task May 24, 2022
@wilkinsona
Copy link
Contributor

I've separated out the handling of the indentation style and Java baseline into a separate issue as I consider that to be a bug.

@wilkinsona wilkinsona added this to the 0.0.32 milestone May 24, 2022
wilkinsona pushed a commit that referenced this pull request May 24, 2022
wilkinsona added a commit that referenced this pull request May 24, 2022
@wilkinsona
Copy link
Contributor

@larsgrefer Thanks for making your first contribution to Spring Java Format.

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

Successfully merging this pull request may close these issues.

2 participants