IDE Projects – What to Include in Your Repository for Best Practices

gitmaintainabilityprogramming practicesproject

I want to add a project which in this case is created in Netbeans but this question is general for most IDE's. It's simply, what should I include in my repository. For example Netbeans creates a nbproject folder, eclipse creates a .settings folder etc. should I include these in my repository, what are the advantages/disadvantages of including or not including project specific settings.

In this case it's a personal project so I don't imagine that other people will start working on it, but it would be nice to add the bare minimum of project settings so the project itself will be easy to start work on different machines.

Best Answer

It really depends on what data it is and should be decided on a case by case basis, perhaps even for individual files. Take a look at the contents of those files. More often than not you can tell what they mean. Stuff like the position and size of the IDE's windows is something you do not want in source control.

But some of the IDE project files are vital project metadata. I don't know Netbeans well, but for eclipse, the .project file tells the IDE what the project's name is, that it's a Java web project, etc. and the .classpath file contains information about source folders and libraries. Some files in the .settings directory can be equally important, e.g. org.eclipse.core.resources.prefs contains information about what encoding should be used for which files.

As project metadata, this stuff very much deserves to be versioned in source control.

Some IDEs can import project metadata from other IDEs. It would be even better to have it in a form that is not tied to a specific IDE.

For Java, there is such a thing: Maven. It imposes strong conventions on the project's structure and allows you to specify project metadata (such as library dependencies) in one point (a file called pom.xml which is in the project's main directory and, of course, in source control). There are plugins which then create IDE project files from the Maven configuration, and others which can automate the project build process, or do just about anything. Sometimes it feels like it makes things unneccessarily complex and it takes some time to learn, but the benefits are generally worth it.

Related Topic