Automating Eclipse project configuration - eclipse

I keep my .project and .classpath files in my source repository. I maintain separate eclipse workspaces for each branch off my trunk. I've found the best way to do this is to recursively copy my trunk workspace (cp -r dev/ branch-foo/). This works great. There are a few other details that facilitate sharing templates and key mappings, but that's not important here. The issue with this solution is that I end up with a workspace that, to no surprise, contains all the trunk projects. I then have to remove all these projects from the workspace manually and then import all the projects in the branch. Not a huge deal, but I'm wondering if something better can be done to automate this process.
I don't see any files that get written to as I add/remove project files in my workspace so I'm assuming eclipse manages these relationships in some internal DB or something. Additionally, I looked into any command-line support eclipse offers for doing this, but don't see anything.
Any thoughts would be much appreciated.
One P.S. - I do see some binary files located in ~/workspace/branch/.metadata/.plugins/org.eclipse.core.resources/.projects/project_name/

Related

Which parts of the project to commit in a team project in Eclipse?

This may be a stupid and easy question but I don't know. I'm working (with other people too) on java projects (java maven projects) with Eclipse and SVN.
When I commit my changes, do I just need to commit the *.java files I changed or the whole java Maven project ?
Thank you
In general, it is a good idea to ask your team for common rules or best practice. So if they want you to only change *.java files, you are better off to contribute only changes that respect this requirement.
In most SW-teams or companies, however, a project is not only made from plain source code. Many projects are composed of .properties files, XML-based configuration, e.g. Maven's project and module definitions found in pom.xml files, or even things like SQL-snippets that is shared for development purposes. From time to time, a developer needs to conduct changes to these non-*.java files. So it might get "blocking" if you would't share these adjustments with your team via a common repository, i.e. here: git or svn.
In essence, ask your team what they expect from you as a contributor OR let your team discuss and make a decision on how you want to organise the project and the code repository on a file level.
Edit: Beware of hidden directories with local configuration information, i.e. the IDE-environment such as properties of the local workspace. These are clearly developer specific things.
Hope it helps.

SAP Cloud Platform WEB IDE Fullstack .che folder

Should we remove the .che folder from Git when we use Web IDE Full-Stack?
The rule of thumb is to never include IDE-specific files into a Git repository. There are several articles and blogs on this and I would point you to this one: IDE Project Files In Version Control - Yes or No? Of Course, Not!
The main drawbacks of having IDE specific files checked-in are the following:
Each IDE would add its own files. E.g. if some of your developers would decide to use VSCode, then you would also have a .vscode folder in there.
The file structure may be different depending on the IDE version (if you use the SAP Web IDE Cloud, this should not be an issue, but it might be if one developer is using the local WebIDE).
The files change very frequently and lead to merge conflicts. E.g. if you do a deploy and also one of your colleagues does a deploy, then you will have a conflict when you want to merge your branch with his (assuming that you work on parallel branches).
The files may contain environment-specific settings. E.g. the name of the project folder, which may actually be different for each developer.
The only clear advantage is that setting up the project after a clone operation might be faster marginally (i.e. the developer which is doing the clone might have to do some settings locally on his copy).

git and eclipse workbench

I'm totally new to git and have a question related to the work bench. I do stuffs in java so I would ask in term of java. When you commit files to git repository, do we commit .java, .class files? Or it is ok to put the whole work bench into the local git folder then commit everything?
It's generally not considered a good idea to commit binary files to any version control system if you can recreate them by simply compiling the source code you also committed. This is especially important with a DVCS as every copy of the repository carries around the redundant data. This might not be a big deal if you're working on a fairly small project, but once the project gets bigger it's a nuisance.
The other problem with committing the .class files or any sort of binary is that any sort of build will show your source tree as "dirty" in multiple places unnecessarily as both the class files and the java files will need comitting.
My advice would be to put the build directories in your projects in .gitignore so git knows not to look at them, then add your source files and the Eclipse project files to git.

Eclipse reference directory outside eclipse project directory but within repository

[Update: See comments]
So lets say I have a structure like this:
/trunk/src
/trunk/platform/linux/[eclipse project]
/trunk/platform/windows/[eclipse project]
I want both project to be able to see /trunk/src, open its files and use the automatic error highlighting on those files. I've tried creating Linked Resources to the directory. This works great with nasty limitations. It never updates unless you re-import and you can't create/delete files. I tried storing a symbolic link in the git repo which apparently as of git 1.6.1 no longer works. I tried anyway and upon cloning the symbolic link comes our broken.
This is really just for ease of access to the main codebase for a multi platform project. The solution need not be elegant but it is important. So I figure I can instruct each dev to just make their own sym link to the main codebase as part of dev environment setup. Tried and these symbolic links created with ln -s do not seem to appear in Eclipse nor can they be imported.
Finally I figured I could create a General Project in /trunk/ within Eclipse. Seems Eclipse is "smart" enough to warn me that this is not possible because it detects other projects deeper in.
Any help appreciated.
First, a comment:
'/trunk/xxx/yyy' is a SVN approach, where all branches/tags are "emulated" as directory.
You don't need them with Git. Two branches (one 'linux', one 'windows') are enough; then you can clone your repo twice, once in a 'windows' directory, one in a 'linux' directory.
Regarding a possible solution:
If the only difference between the linux and the windows platform, regarding eclipse, are the .project and .classpath files, I would actually recommend having only one repo (for your sources), with aforementioned two branches, each one including the sources and the eclipse files (tailored for each platform).
That way, the solution is much easier to maintain: one repo, one structure. Two branches.

What Eclipse metadata files should be in the repository?

I'm working on a new project with a full ANT build. I use eclipse to write my code, and I would like others to be able to check out the project to have a full working eclipse workspace. I do not want to have specific user settings committed though.
What files and directories should I have in source control?
(I'd rather not just go grab a plugin - I prefer more control over what goes in the repository)
We just put .project and .classpath in our repository, and that's sufficient to make it work "out of the box" for new developers. I'd like to have other stuff (run configurations come to mind), but haven't figured out how.
We use Subversion, so I put these files in a separate directory and defined svn:externals on that directory to point to the actual code, leaving it unpolluted by IDE-specific files.
Per request in the comments, here are the external that we use. Nothing complicated going on here:
Properties on 'svn://dev/trunk/IDEs/eclipse/runtime':
svn:ignore
bin
.fbprefs
cobertura.ser
.settings
svn:externals
lib/bin svn://dev/trunk/lib/bin
runtime svn://dev/trunk/runtime