Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing a single .editorconfig file across multiple projects

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.

like image 843
David DeMar Avatar asked Mar 29 '18 22:03

David DeMar


People also ask

What is a .EditorConfig file?

The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.

How do I create a .EditorConfig file?

Add an EditorConfig file to a project You can also select a folder in your project or solution to add the . editorconfig file to. From the menu bar, choose Project > Add New Item, or press Ctrl+Shift+A.

Should we commit EditorConfig files to Git?

It depends. If the files are specific to your project, then it is appropriate to commit them. If they are appropriate for your work flow, then it is not.

How do I use EditorConfig in Visual Studio?

Adding a new EditorConfig fileOpen your project in Visual Studio for Mac. Select either the solution or project node that you wish to add the EditorConfig file to. Adding the file to the solution directory applies the . editorconfig settings to all projects in the solution.


1 Answers

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": "."
    }
  ]
}
like image 167
Tomas Bjerre Avatar answered Oct 26 '22 00:10

Tomas Bjerre