To check in, or not check in, the entire Eclipse p

2020-02-18 04:39发布

I'm soon going to check in the very first commit of a new Java project. I work with Eclipse Ganymede and a bunch of plug ins are making things a little bit easier.

Previously I've been part of projects where the entire Eclipse project was checked in. It's quite convenient to get the project settings after a check out. However this approach still was not problem free:

  • I strongly suspect that some Eclipse configuration files would change without user interaction (from when I used Eclipse Europa), making them appear as changed (as they were changed, but not interactively) when it's time to do a commit.
  • There are settings unique to each development machine as well as settings global for all developers on a project. Keeping these apart was hard.
  • Sometime if the Eclipse version was different from others Eclipse would get angry and mess up the project configuration. Another case is that it change the format so it gets updated, and if commited messes up the configuration for others.

For this specific project I have another reason not to commit the project files:

  • There might be developers who prefer NetBeans which will join the project later. However they won't join within the coming months.

How do you organize this? What do you check into versioning control and what do you keep outside? What do you consider best practice in this kind of situation?

12条回答
唯我独甜
2楼-- · 2020-02-18 04:57

I recommend to use maven so that the entire life cycle is outside of any IDE. You can easily create an eclipse project with it on the command line and you can use whatever you want, if it's not eclipse. It has it's quirks but takes out a lot of bitterness when it comes to dependencies and build management.

查看更多
祖国的老花朵
3楼-- · 2020-02-18 05:02

Try to port your project to a build system like maven. It has everything you need to get the same experience of the project on every machine you use.

There are plugins for just everything. Like the eclipse plugin. You just type "mvn eclipse:eclipse" and the plugin generates your entire ready to work eclipse project.

To give the answer to your question. Never check in files that are not being used by your project at any time in the development cycle. That means that metadata files like eclipse properties etc. should never be checked in in a SCM.

查看更多
家丑人穷心不美
4楼-- · 2020-02-18 05:03

I only ever check in things are done by humans, anything else that is generated (whether automaticly or not) should be easy to regenerate again and is liable to change (as you've stated). The only exeption to this is when the generated files are hard (requires alot of human intervention ;) ) to get it right. How ever things like this should really be automated some how.

查看更多
我想做一个坏孩纸
5楼-- · 2020-02-18 05:03

I'd suggest having the actual project files ignored by the version control system due to the downsides you mentioned.

If there is enough consistent information in the project settings that there would be benefit from having it accessible, copy it to a location that Eclipse doesn't treat as special, and you'll have it available to work with on checkout (and copy back to where Eclipse will pay attention to it). There is a decent chance that keeping the actual project files separate from the controlled ones will result in loss of synch, so I'd only suggest this if there is clear benefit from having the settings available (or you're confident that you'll be able to keep them synchronised)

查看更多
迷人小祖宗
6楼-- · 2020-02-18 05:04

Don't. Only check in the source code of your projects.

查看更多
Melony?
7楼-- · 2020-02-18 05:05

At a minimum you should be check-in the .project and .classpath files. If anybody on your team is hard-coding an external JAR location in the .classpath you should put them up against the wall and shoot them. I use Maven to manage my dependencies but if you are not using maven you should create user libraries for your external JARs with with a consistent naming convention.

After that you need to consider things on a plug-in by plug-in basis. For example I work with Spring so I always check-in the .springBeans and likewise for CheckStyle I always check-in the .checkstyle project.

It gets a bit trickier when it comes to the configuration in the .settings folder but I generally check-in the following if I change the default settings for my project and want them shared with the rest of the team:

  • .settings/org.eclipse.jdt.ui.prefs - it contains the settings for the import ordering
  • .settings/org.eclipse.jdt.core.prefs - it contains the settings for the compiler version

In general I haven't noticed Ganymede modifying files without me modifying the project preferences.

查看更多
登录 后发表回答