Search code examples
giteclipseeclipse-emf

What files should be commited in the case of an Eclipse modeling project?


In your opinion, what Eclipse configuration files need to be included in git commits and what are those that should be ignored?

Specifically, I am talking about an Ecore/Xtext project using Eclipse modeling framework under ubuntu.

The files I am thinking of are : .DS_Store .metadata .classpath .project .settings

I have a doubt about META-INF build.properties plugin.properties

And what about .gitignore itself?

I believe generated source files in src and src.gen should be included in commits since I may need to edit them in the future. I am right? Or maybe should I include them only once I edit them?

Thank you in advance,


Solution

  • Let me preface that many people say you shouldn't commit any IDE specific files to avoid restricting projects to a particular IDE. But in my experience when working with Eclipse plugins/EMF/Xtext projects it makes everything easier to only use Eclipse and include them. You might not need them if you use a pure maven-tycho build process though.

    Anyway here is what I would commit.

    Project files that should definitely be committed, as these are part of the final product:

    • META-INF contains important plugin meta data, like the MANIFEST.MF which is essential to the build and at runtime
    • plugin.properties is used to localize the MANIFEST.MF

    Eclipse-specific files that should be committed:

    • .project is required to import the projects correctly
    • build.properties is required to build the project correctly
    • .settings contains plugin specific metadata, for example which Java versions
    • .classpath is as far as I know mostly generated and updated from other sources but could contain other information that you need. I never had any issues committing it.

    Files that should usually be committed:

    • .gitignore - it makes sense to have common rules for everyone. If anyone needs their own local ignore pattern, they should use .git/info/exclude instead which is never commited.
    • src-gen - best practices often say that generated files should not be committed but every project I work at some point included this folder. Generating Java classes from large .ecore files can take some time. But even more important is, that if someone changes the model, everyone else has to generate src-gen after checkout of that commit. In fast moving projects that means you may have to generate src-gen after each checkout. If you checkout older commits or switch branches you have generate src-gen. If you forget, your Eclipse workspace will be littered with errors. Generating on checkout could likely be scripted but its still a hassle. So just regenerate src-gen when you change the model and spare everyone else from doing it every time. (By the way I would still avoid changing the files manually if possible. It's rarely required and can usually be avoided)

    Files that shouldn't be committed:

    • .metadata in the workspace. This contains e.g. information about projects in the workspace (including local projects not under version control) and likely contains user-specific paths.
    • target and bin folders
    • xtend-gen if you use Xtend. Unlike src-gen, this one folder more ephemeral and is automatically regenerated by Eclipse when building.

    Keep in mind that IDE plugins could add additional files that may are or are not needed by others.

    You could also take a look at Github's .gitignore template for Eclipse. This template does exclude .settings though, which I usually would commit, if everyone in the team uses the same IDE plugins with the same configuration. It also excludes *.launch files, which you likely want to commit if your application requires complex launch configuration like often is the case for plugin projects.