-
Notifications
You must be signed in to change notification settings - Fork 135
IntelliJ: Format on save when using PJF #1151
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
Conversation
Generate changelog in
|
| } | ||
| appendNode('option', [name: 'configurationPath', value: '']) | ||
| appendNode('inclusions').appendNode('set').with { | ||
| appendNode('option', [value: 'src/.*\\.java']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, so it's a bit tricky as if people already use this plugin (and have configured it for a project) then we do nothing.. but in the majority of cases, this is probably what people want.
An unsolved problem I will add to the description is how to deal with changing flags / how do we know what's safe to update because we set it up that way vs the user set it up that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have to look into what other options the plugin exposes, but we may want to narrow what users can configure to a very narrow set of flags
gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/GroovyXmlUtils.groovy
Outdated
Show resolved
Hide resolved
|
|
||
| // Suggest and configure the "save actions" plugin if Palantir Java Format is turned on. | ||
| if (project == project.rootProject) { | ||
| IdeaModel ideaRootModel = project.extensions.findByType(IdeaModel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have the ideaRootModel above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah but it's needlessly trapped inside afterEvaluate. Basically I think the code above is beyond gross (it reapplies the same steps to the root model from every single subproject) and so will not touch it, with an eye to refactor it in another PR.
gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy
Show resolved
Hide resolved
| */ | ||
| private static void configureSaveActions(Node rootNode) { | ||
| GroovyXmlUtils.matchOrCreateChild(rootNode, 'component', [name: 'SaveActionSettings'], [:]) { | ||
| // Configure defaults if this plugin is configured for the first time only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this to allow users to override the configuration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, or they might have configured this plugin already for this project and then we don't want to override their configuration
gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy
Outdated
Show resolved
Hide resolved
|
Released 2.48.0 |
Before this PR
A common complaint we've seen with Palantir Java Format is that it's quite opinionated in what your code should look like, so people often forget to format, then get red checks on CI.
After this PR
==COMMIT_MSG==
When palantir-java-format is applied to a repo, configure the intellij project to auto-format on save.
==COMMIT_MSG==
Possible downsides?