Add Gradle tasks and Git hooks for IntelliJ-based code formatting (#15535) - #15555
Conversation
56037b6 to
e886bca
Compare
|
@sanjana2505006 we explicitly decided to not auto-install the hook so it would be optional if people wanted it. |
|
To revert the changes in build.gradle, remove the added plugin block and revert the lambda expressions in the ext block back to method references. build.gradle |
| private static void doNotApplyStylingToTests(Project project) { | ||
| project.tasks.named('checkstyleTest') { | ||
| it.enabled = false // Do not check test sources at this time | ||
| if (project.tasks.names.contains('checkstyleTest')) { |
There was a problem hiding this comment.
Can you help me understand why this change was necessary?
There was a problem hiding this comment.
I originally added this to focus the initial rollout on production source code and avoid overwhelming the PR with style violations from the existing test suite. However, I agree that tests should ideally follow the same standards. Would you prefer that I remove this block and enable styling for tests as well?
There was a problem hiding this comment.
While we do need to eventually format our tests, we have agreed to not do so at this time. We should leave styles and only adjust the styles when working on the tests.
| throw new RuntimeException("IntelliJ code style settings not found at ${settingsFile.absolutePath}") | ||
| } | ||
|
|
||
| project.exec { ExecSpec exec -> |
There was a problem hiding this comment.
Take a look at the publishAllToMavenLocal task for how to do in this a modern Gradle way without referencing project .
I have reverted the |
7f21945 to
0ca94f3
Compare
jdaugherty
left a comment
There was a problem hiding this comment.
@borinquenkid Can you please take a look at this as well? I think this is very close to being mergeable.
| } | ||
| } | ||
|
|
||
| private static void doNotApplyStylingToTests(Project project) { |
There was a problem hiding this comment.
This needs to stay. We decided as a project to not yet do styling changes to the tests.
|
@sanjana2505006 if you can get the rest of these comments implemented, I'll ping another reviewer and we can get this merged. |
5251fb7 to
2322979
Compare
Done, please have a look and let me know if there's anything I need to update. |
| ext { | ||
| isReproducibleBuild = System.getenv("SOURCE_DATE_EPOCH") != null | ||
| buildInstant = java.util.Optional.ofNullable(System.getenv("SOURCE_DATE_EPOCH")) | ||
| .filter(s -> !s.isEmpty()) |
Made-with: Cursor
769f735 to
ae7d7d1
Compare
|
@matrei this looks accepatble to me. Do you agree? If so, we can merge. |
|
@sanjana2505006 Can you please take a look at @matrei feedback so we can get this merged? |
|
@matrei this feedback is complete, can you please confirm it's ok to merge? |
|
@matrei hold off. there's a problem - the format.sh / format bat is the correct way to invoke this. The jetbrains toolbox installs an idea but it assumes it's not running / will only return once the app is closed. I'm going to rework this. |
|
@matrei this should be fixed now. You should be able to invoke the formatting independently of intellij running. |
✅ All tests passed ✅🏷️ Commit: bb41c25 Learn more about TestLens at testlens.app. |
Co-authored-by: Mattias Reichel <mattias.reichel@gmail.com>
Co-authored-by: Mattias Reichel <mattias.reichel@gmail.com>
Co-authored-by: Mattias Reichel <mattias.reichel@gmail.com>
Co-authored-by: Mattias Reichel <mattias.reichel@gmail.com>
Added a
formatCodeGradle task that uses the IntelliJ CLI formatter to keep our code style consistent. I also added aninstallGitHookstask that sets up a git pre-commit hook to automatically format staged files. This should help avoid formatting issues during review. Fixes #15535.