spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Improve project setup for IntelliJ IDEA

Open vpavic opened this issue 3 years ago • 7 comments

At present, the IntelliJ IDEA project setup has some manual steps - see Import additional code style section of the Working with the Code wiki page that refers to idea/codeStyleConfig.xml.

This step could be a bit easier by checking in this file in version control under it's natural place (that is, under .idea/codeStyles). This is also suggested by Jetbrains - see the article on How to manage projects under Version Control Systems.

The manual step on project setup isn't the only downside of the current setup:

  • any updates to the file from the team require manual export (since it's natural location is git ignored)
  • contributors need to re-import to pick up any updates

Additionally, on top of the code style config, some additional things like inspection profiles could also be shared. For example, the Instance field access not qualified with 'this' inspection is helpful because IDEA will then qualify fields with this when it generates any code (for instance, field accessors). This helps because it prevents Checkstyle errors and therefore saves time.

Basically, I'm proposing to ditch the mentioned manual step in favor of checking in .idea/codeStyles and .idea/inspectionProfiles directories. In terms of .gitignore that boils down to something like this:

!.idea/
.idea/*
!.idea/codeStyles
!.idea/inspectionProfiles

vpavic avatar Jan 10 '22 22:01 vpavic

Why not just use and extend the .editorconfig instead?

dreis2211 avatar Jan 10 '22 22:01 dreis2211

Also, may be add pre-requiste details for PKIX Certificate Issues, when configuring the unsecured environments.

anilkumarkatta204 avatar Jan 10 '22 23:01 anilkumarkatta204

In the past, importing a project with an existing .idea directory led to a change of behavior in the way updates were applied so we'd have to test this first.

snicoll avatar Jan 11 '22 08:01 snicoll

I've opened a draft PR to take a look at this - see #29446.

... led to a change of behavior in the way updates were applied ...

@snicoll, can you clarify this? I'm not sure I understood what behavior and updates exactly did you refer to.

Why not just use and extend the .editorconfig instead?

@dreis2211 I like .editorconfig as means of ensuring basic settings are respected everywhere but find it less attractive for expressing richer capabilities of IDE like IntelliJ as it will never be able to do the same job there.

vpavic avatar Jan 17 '22 22:01 vpavic

can you clarify this?

I can't without testing it. I've tried to do such a thing in the past and the IDE had a different behavior with regards to updating the project configuration when something in the build changes that led the IDE to be out-of-sync.

snicoll avatar Jan 18 '22 08:01 snicoll

@vpavic I was under the impression that you can export IDEA settings either via xml or .editorconfig and that the functionality is equivalent...

dreis2211 avatar Jan 18 '22 08:01 dreis2211

... you can export ...

Exactly the reason why I'm proposing this, to avoid the need to export (or import) settings. Requiring manual actions makes both the project setup and the maintenance of these settings more difficult.

While I generally like EditorConfig as a way of ensuring baseline code style IMO it's not as good as native configuration because:

  • it requires another IDE plugin
  • if used as a dumping group for various editor/IDE-specific settings it becomes messy and therefore difficult to maintain
  • it cannot (to my knowledge) cover stuff like inspection settings

vpavic avatar Jan 21 '22 08:01 vpavic

Closing in favor of PR https://github.com/spring-projects/spring-boot/pull/29446

snicoll avatar Jul 24 '23 12:07 snicoll