10

My team maintains several Java repositories in GitHub. Each of them has an .editorconfig file in the root folder and they're all exactly the same. This makes maintaining them a bit of a pain because they all have to be updated individually.

All of us use IntelliJ, which has a feature that will download checkstyle rules from a URL, but there doesn't seem to be a way to do that with the .editorconfig rules.

All of our projects use Maven. Is there any way to make the .editorconfig file accessible through an API and have the projects configured to automatically download it and put it in the root folder?

For anyone not familiar with EditorConfig, more info is here.

David DeMar
  • 2,390
  • 2
  • 32
  • 45

3 Answers3

2

I made a tool to solve this kind of problem. It is developed as an NPM package but it is basically just a command line tool so it should work for this case. If you execute something like npx your-dictator-name@version with Exec Maven Plugin.

The tool is called Dictator Builder and helps create "dictators". A dictator is the command line tool that contains "dictatables", your .editorconfig can be part of a "dictatable".

In your case you could have a .dictatable-config.json with something like:

{
  "message": "Copy editorconfig",
  "actions": [
    {
      "copyFrom": ".editorconfig",
      "target": "."
    }
  ]
}
Tomas Bjerre
  • 3,270
  • 22
  • 27
0

I have a similar situation and I have been solving this by using hardlinks via mklink /h. So far I have not had any issues with it as with some users having issues with softlinks (.editorconfig in shared Git repository) I am not clear what the issue with the softlink is.

Jazz.
  • 458
  • 4
  • 12
-3

Quoting that same EditorConfig docs you mentioned:

When opening a file, EditorConfig plugins look for a file named .editorconfig in the directory of the opened file and in every parent directory. A search for .editorconfig files will stop if the root filepath is reached or an EditorConfig file with root=true is found.

Therefore the most convenient and easy-to-manage approach is to make a single .editorconfig file and place it somewhere at the parent dir of all your repositories. That file has to have the root=true line in it.

This can perhaps be further improved by storing the file in one repository and making a symlink to it in the parent dir:

cd <parent_dir_for_all_repos>
ln -s .../path/to/.editorconfig
yktoo
  • 2,696
  • 1
  • 23
  • 35
  • 1
    I think that this might have been downvoted since OP wants to commit the .editorConfig file with the repo and your solution does not address this. Still I think that it might be a good solution. – Jazz. Feb 21 '23 at 10:40