Skip to content

Conversation

@dansanduleac
Copy link
Contributor

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?

@changelog-app
Copy link

changelog-app bot commented Jan 8, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

When palantir-java-format is applied to a repo, configure the intellij project to auto-format on save.

Check the box to generate changelog(s)

  • Generate changelog entry

}
appendNode('option', [name: 'configurationPath', value: ''])
appendNode('inclusions').appendNode('set').with {
appendNode('option', [value: 'src/.*\\.java'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link
Contributor Author

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.

Copy link
Contributor

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


// Suggest and configure the "save actions" plugin if Palantir Java Format is turned on.
if (project == project.rootProject) {
IdeaModel ideaRootModel = project.extensions.findByType(IdeaModel)
Copy link
Contributor

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

Copy link
Contributor Author

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.

*/
private static void configureSaveActions(Node rootNode) {
GroovyXmlUtils.matchOrCreateChild(rootNode, 'component', [name: 'SaveActionSettings'], [:]) {
// Configure defaults if this plugin is configured for the first time only
Copy link
Contributor

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?

Copy link
Contributor Author

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

@bulldozer-bot bulldozer-bot bot merged commit 1f4910a into develop Jan 9, 2020
@bulldozer-bot bulldozer-bot bot deleted the ds/formatter-save-actions branch January 9, 2020 14:47
@svc-autorelease
Copy link
Collaborator

Released 2.48.0

This was referenced Jan 9, 2020
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.

4 participants