How does Eclipse determine which projects to load for a particular workspace? - eclipse

Does anyone know how Eclipse determines which projects are in a particular workspace? Is there a config file somewhere with this info? I have struggled (in vain) for several hours trying to figure this out. I'd like to be able to edit this config / check it into SVN...

I think Eclipse works much better if you manage just the individual projects in your version control system.
You can publish the set of projects that make up a workspace as a Project Set File (an XML file that can be created as Export > Team > Project Set), which you could put in your repository. This file contains the repository location for all projects, so that they can be checked out all at once.

I agree with Thilo that it is not a good idea to put the workspace metadata into your version control system.
However, in the spirit of answering the question and letting others make their own value decisions: The directory ${workspace_loc}/.metadata/.plugins/org.eclipse.core.resources/.projects should contain one directory for each project that eclipse uses to keep track of where the project is on disk and a whole bunch of other information.

Related

How to share Eclipse workspace and project settings across a team? [duplicate]

Which Eclipse files is it appropriate to put under source control, aside from the sources obviously?
In my project, specifically, I'm wondering about:
.metadata/*
project-dir/.project
project-dir/.classpath
project-dir/.settings/*
If there are any of these for which it depends, please explain your guidelines.
Metadata should not be managed in source control. They contain mostly data relevant to your workspace.
The only exception is the .launch XML files (launcher definition).
They are found in
[eclipse-workspace]\.metadata\.plugins\org.eclipse.debug.core\.launches
And they should be copied into your project directory: When your project is refreshed, those configurations will be displayed in the "Run configuration" dialog.
That way, those launch parameter files can be also managed into the SCM.
(Warning: Do uncheck the option "Delete configurations when associated resource is deleted" in the Run/Launching/Launch Configuration preference panel: It is common to soft-delete a project in order to import it back again - to force a reinitialization of the eclipse metadata. But this option, if checked, will remove your detailed launch parameters!)
project-dir/.project
project-dir/.classpath
project-dir/.settings/*
should be in your SCM (especially .project and .classpath according to the Eclipse documentation).
The goal is that anyone can checkout/update his/her SCM workspace and import the Eclipse project into the Eclipse workspace.
For that, you want to use only relative paths in your .classpath, using linked resources.
Note: it is better if project-dir refers to an "external" project directory, not a directory created under the eclipse workspace. That way, the two notions (eclipse workspace vs. SCM workspace) are clearly separated.
As ipsquiggle mentions in the comment, and as I have alluded to in an old answer, you can actually save the launching configuration as shared file directly in your project directory. All launching configuration can then be versioned like the other project files.
(From the blog post Tip: Creating and Sharing Launch Configurations from KD)
I am currently working on a project where we have the .project and .cproject files under source control. The idea was that settings related to library paths and link directives would propagate across the team.
In practice it hasn't worked very well, merges almost always come back in a conflicted state which need to be deconflicted outside of eclipse and then the project closed and reopened for the changes to take effect.
I wouldn't recommend keeping them in source control.
It's worth nothing that CDT configuration files are not source-control-friendly. There's a bug filed for .cproject files changing very frequently and causing conflicts, see Sharing cdt-project files in repository always causes conflicts.
Some projects, like those using Maven, like to generate the .project files based on POMs.
That said, other than that - .metadata should NOT be in source control. Your project will have to make a determination about whether projectdir/.settings does, based on how you plan to manage standards and such. If you can honestly trust your developers to set up their environment based on the standard, and you don't have to customize anything special for any project, then you don't need to put them in. Me, I recommend configuring every project specifically. This allows devs to work on multiple projects' stuff in the same workspace without having to change default settings back and forth, and it makes the settings very explicit, overriding whatever their default settings are to match the project's standards.
Only difficult part is making sure they all stay in sync. But in most cases you can copy the .settings files from project to project. If there are any you specifically don't want in source control, do the equivalent of setting svn:ignore for them, if your SCM supports it.
The .classpath file is definitively a good candidate for checking into scm as setting it by hand can be a lot of work and will be difficult for new devs getting into the project. It is true it can be generated from other sources, in which case you would check in the other source.
As for .settings, it depends on the settings. This is a grey area, but some settings are almost mandatory and it is convenient to be able to check out a project, import it in Eclipse and have everything set up and good to go.
At our project, we therefore maintain a copy of the .settings folder called CVS.settings and we have an ant task to copy it to .settings. When you get the project from CVS, you call the 'eclipsify' ant task to copy the default settings to the new .settings folder. When you configure settings that are needed by everyone developing on the project, you merge those back into the CVS.settings folder and commit that to CVS. This way saving settings in SCM becomes a conscious process. It does require devs to merge those settings back into their .settings folders from time to time when big changes are checked in. But it's a simple system that works surprisingly well.
I'd say none of them. They most likely contain information that is relevant only to your workstation (I'm thinking about paths for libraries and all). Also what if someone in your team is not using Eclipse?
Consider:
.classpath
.project
.launch
These SHOULD be in version control as long as you stick to using project-relative paths. This allows other developers to check out the project and start working right away without having to go through all the setup pain that other developers went through as well.
You might be tempted to include .metadata in version control as well so Eclipse developers can check out an entire workspace and have it preconfigured with all the right projects, but it includes a lot of user specific information that anytime anybody works on it, it will change, so I would advise to NOT INCLUDE .metadata. It's easy to build a local workspace just by importing all existing Eclipse projects.
I have spent too many hours configuring eclipse workspace settings for new colleagues (and myself). What I ended up doing eventually was copying my own .metadata to the new developer machine.
If you are working on a team, then I think the following are very good candidates to keep under version control:
Installed JREs and their names
Server Runtime Environments
Java Editor Templates
Version Control Keyboard Shortcuts
Plugin settings that do not provide project specific settings
Maven settings
Preconfigured Perspectives
...
I haven't tried to put anything in .metadata under version control, but I'm using version control for these files for ten years now:
project-dir/.project
project-dir/.classpath
project-dir/.settings/*
The main reason is that Eclipse sometimes damages those files. Without version control, you will get weird and hard to track errors. With version control, you can immediately see "Why is it trying to deploy test classes???" or "Why is Maven and Eclipse using the same classpath?" (leading to https://bugs.eclipse.org/bugs/show_bug.cgi?id=430605).
With version control, you can see when it happens and easily go back to a working set of config files.
If you use m2e: You can import the project now with the fast "Import existing project" instead of the slow "Import Maven project".
The drawback of this approach is that Eclipse seems to randomly change some of those files. Most plugins keep them stable but some use HashMap instead of, say, LinkedHashMap so the order of elements changes all the time. This means there is an additional step when you commit: Check for any modified settings and handle them, first.
It also means that the whole team has to agree on some standards: Like which warnings should be enabled. It's interesting that many people see this as a additional problem - as if they weren't working together.
In my experience, it takes a couple of weeks until those files stabilize. Partly because you gradually learn how to tweak Eclipse, partly because people learn what not to touch. You can think of this as lost time or time spent to improve the quality of your work environment (like keeping your desk uncluttered).
There is a bonus advantage of the "Commit settings first": It gets people to commit more often and in smaller pieces (i.e. more like "one thought at a time" instead of "on feature at a time plus a thousand of other, unrelated things that I just happened to stumble upton ... what was I working on again?").
As a seasoned developer, I've come to prefer the "small commits" way of working; it's just easier to stay on track and you tend to sort your thoughts and changes into smaller, more manageable steps. This helps to reduce the level of complexity. Everyone can juggle with one ball, no one can juggle with 20.
PS: For certain setting files, I have unit tests to make sure known errors don't creep in like the "trying to deploy tests" in WTP. That helps in the initial phase "commit everything, I'm too busy" phase.

XPAGES: Build path contains duplicate entry: 'org.eclipse.jdt.launching.JRE_CONTAINER'

I am trying to run an Xpage locally (in Chrome if it makes any difference) from a local NSF and am receiving the error:
Build path contains duplicate entry: 'org.eclipse.jdt.launching.JRE_CONTAINER'
I have copied all the ExtLib Features and Plugins to the correct directories as required.
Anonymous is set to Author.
I cannot find any information on how to resolve this. There was an open ticket on OpenNTF 6 years ago but no resolution.
[Update]
As Jesse Gallagher pointed out on Twitter, you can access the .classpath file without going through the ODP setup via the Navigator perspective. I would still recommend setting up source control since it gives you:
local change history in DDE (even if you don't use the ODP in git/hg)
the ability to track any changing file during development, aka- a rogue change to your .classpath file (I recommend installing Cameron Gregor's Swiper plugin)
is fairly easy to set up
as a developer, version control is the best way to cover your butt
[/Update]
I believe you quite literally have a duplicate entry in your NSF's build class path. This has to do with the Eclipse version Domino Designer is based on is being confused by its defined class path. I recommend the following:
if you don't have it set up already, set up source control for your NSF
open the (hidden) file .classpath, which can be found in the root of your On Disk Project (ODP) folder with a trusty text editor (Notepad++, etc.)
search for org.eclipse.jdt.launching.JRE_CONTAINER
if you find more than one, you will need to deconflict your class path (aka- remove one; it may be best to make a backup of the file)
if you don't have "Build Automatically" checked (in your Project menu), you may need to open Package Explorer and right-click your ODP, then perform a "Sync with NSF"
You should be able to de-conflict your build path via the Project > Build Path screen, but this is an easy way to search the whole thing in one shot.
Here's an example the .classpath file from a working app.
An example of a situation where others (using gradle, in this case) ran into a duplicate issue with org.eclipse.jdt.launching.JRE_CONTAINER.
Setting up source control with an NSF, right-click NSF, Team Development, Set Up Source Control:
Note: If you need a little more info on how to set up source control or want to know more about where to park the ODP (aka- if you haven't done this before), I recommend checking out David Leedy's Notes in 9 episode 131: Using SourceTree for Better XPages Source Control. Even if you don't use SourceTree, it's worth it to understand that the ODP should not be placed in your Notes Data directory, etc.

Eclipse Won't Load My Workspace Contents

I recently deleted an account I was using on my Mac (Mavericks if means anything, although it shouldn't). I was using that account to run eclipse and saved all my files on a disc image before deleting. I took all the files and switched them into my current workspace but now they don't show up in the package explorer(although I can access them from My Documents). Can someone please tell how to make them show up in the panel? It's getting very time consuming to constantly have to open them through Docs.
If the files are in projects that Eclipse does not know about you need to do File / Import... / General / Existing Projects into Workspace.
If the files are in existing projects use File / Refresh to get Eclipse to pick up the new files.
If that doesn't work, you can always try recreating your project and then adding all the classes and other files through the file menu, add existing item. This way you can maintain the integrity of your project withouth having to change any of the packages or classes inheritance.
Hope this helps.

Working on eclipse project in subversion

All,
I have a 20 member dev team working on a development project.
To provide greater control we have created a workspace with necessary projects and configurations (like project preferences, set-ups etc) in IBM RAD.
The idea is to have the pre-configured project in subversion so that when the dev team members checkout the project they get a complete workspace, so that they do not have to configure setups them selves.
However the problem is everytime someone checks out the workspace IBM RAD will also edit the .metadata (and some other folders and properties file) folder that has been checked in.
Idea is the developer should not have to change anything except the source code folders or application specific files.
I think many other teams might have faced situations like this.
Can anybody provide the best practices/process/references on how this is done in development projects?
Thanks
I think svn ignore will solve your problem.
check http://svnbook.red-bean.com/en/1.1/ch07s02.html
The svn:ignore property contains a
list of file patterns which certain
Subversion operations will ignore.
Perhaps the most commonly used special
property, it works in conjunction with
the global-ignores run-time
configuration option (see the section
called “Config”) to filter unversioned
files and directories out of commands
svn status, svn add, and svn import.
You cannot stop IBM RAD from updating .metadata folder and Eclipse doesn't support splitting workspace folder as it does for the configuration folder.
The best solution would be to setup your build scripts to be able to setup your workspace based on some .zip file(s), where you've captured the required settings for the workspace. This will give the closest thing to automatic workspace setup without having to deal constantly with changed files in .svn.

Which Eclipse files belong under version control?

Which Eclipse files is it appropriate to put under source control, aside from the sources obviously?
In my project, specifically, I'm wondering about:
.metadata/*
project-dir/.project
project-dir/.classpath
project-dir/.settings/*
If there are any of these for which it depends, please explain your guidelines.
Metadata should not be managed in source control. They contain mostly data relevant to your workspace.
The only exception is the .launch XML files (launcher definition).
They are found in
[eclipse-workspace]\.metadata\.plugins\org.eclipse.debug.core\.launches
And they should be copied into your project directory: When your project is refreshed, those configurations will be displayed in the "Run configuration" dialog.
That way, those launch parameter files can be also managed into the SCM.
(Warning: Do uncheck the option "Delete configurations when associated resource is deleted" in the Run/Launching/Launch Configuration preference panel: It is common to soft-delete a project in order to import it back again - to force a reinitialization of the eclipse metadata. But this option, if checked, will remove your detailed launch parameters!)
project-dir/.project
project-dir/.classpath
project-dir/.settings/*
should be in your SCM (especially .project and .classpath according to the Eclipse documentation).
The goal is that anyone can checkout/update his/her SCM workspace and import the Eclipse project into the Eclipse workspace.
For that, you want to use only relative paths in your .classpath, using linked resources.
Note: it is better if project-dir refers to an "external" project directory, not a directory created under the eclipse workspace. That way, the two notions (eclipse workspace vs. SCM workspace) are clearly separated.
As ipsquiggle mentions in the comment, and as I have alluded to in an old answer, you can actually save the launching configuration as shared file directly in your project directory. All launching configuration can then be versioned like the other project files.
(From the blog post Tip: Creating and Sharing Launch Configurations from KD)
I am currently working on a project where we have the .project and .cproject files under source control. The idea was that settings related to library paths and link directives would propagate across the team.
In practice it hasn't worked very well, merges almost always come back in a conflicted state which need to be deconflicted outside of eclipse and then the project closed and reopened for the changes to take effect.
I wouldn't recommend keeping them in source control.
It's worth nothing that CDT configuration files are not source-control-friendly. There's a bug filed for .cproject files changing very frequently and causing conflicts, see Sharing cdt-project files in repository always causes conflicts.
Some projects, like those using Maven, like to generate the .project files based on POMs.
That said, other than that - .metadata should NOT be in source control. Your project will have to make a determination about whether projectdir/.settings does, based on how you plan to manage standards and such. If you can honestly trust your developers to set up their environment based on the standard, and you don't have to customize anything special for any project, then you don't need to put them in. Me, I recommend configuring every project specifically. This allows devs to work on multiple projects' stuff in the same workspace without having to change default settings back and forth, and it makes the settings very explicit, overriding whatever their default settings are to match the project's standards.
Only difficult part is making sure they all stay in sync. But in most cases you can copy the .settings files from project to project. If there are any you specifically don't want in source control, do the equivalent of setting svn:ignore for them, if your SCM supports it.
The .classpath file is definitively a good candidate for checking into scm as setting it by hand can be a lot of work and will be difficult for new devs getting into the project. It is true it can be generated from other sources, in which case you would check in the other source.
As for .settings, it depends on the settings. This is a grey area, but some settings are almost mandatory and it is convenient to be able to check out a project, import it in Eclipse and have everything set up and good to go.
At our project, we therefore maintain a copy of the .settings folder called CVS.settings and we have an ant task to copy it to .settings. When you get the project from CVS, you call the 'eclipsify' ant task to copy the default settings to the new .settings folder. When you configure settings that are needed by everyone developing on the project, you merge those back into the CVS.settings folder and commit that to CVS. This way saving settings in SCM becomes a conscious process. It does require devs to merge those settings back into their .settings folders from time to time when big changes are checked in. But it's a simple system that works surprisingly well.
I'd say none of them. They most likely contain information that is relevant only to your workstation (I'm thinking about paths for libraries and all). Also what if someone in your team is not using Eclipse?
Consider:
.classpath
.project
.launch
These SHOULD be in version control as long as you stick to using project-relative paths. This allows other developers to check out the project and start working right away without having to go through all the setup pain that other developers went through as well.
You might be tempted to include .metadata in version control as well so Eclipse developers can check out an entire workspace and have it preconfigured with all the right projects, but it includes a lot of user specific information that anytime anybody works on it, it will change, so I would advise to NOT INCLUDE .metadata. It's easy to build a local workspace just by importing all existing Eclipse projects.
I have spent too many hours configuring eclipse workspace settings for new colleagues (and myself). What I ended up doing eventually was copying my own .metadata to the new developer machine.
If you are working on a team, then I think the following are very good candidates to keep under version control:
Installed JREs and their names
Server Runtime Environments
Java Editor Templates
Version Control Keyboard Shortcuts
Plugin settings that do not provide project specific settings
Maven settings
Preconfigured Perspectives
...
I haven't tried to put anything in .metadata under version control, but I'm using version control for these files for ten years now:
project-dir/.project
project-dir/.classpath
project-dir/.settings/*
The main reason is that Eclipse sometimes damages those files. Without version control, you will get weird and hard to track errors. With version control, you can immediately see "Why is it trying to deploy test classes???" or "Why is Maven and Eclipse using the same classpath?" (leading to https://bugs.eclipse.org/bugs/show_bug.cgi?id=430605).
With version control, you can see when it happens and easily go back to a working set of config files.
If you use m2e: You can import the project now with the fast "Import existing project" instead of the slow "Import Maven project".
The drawback of this approach is that Eclipse seems to randomly change some of those files. Most plugins keep them stable but some use HashMap instead of, say, LinkedHashMap so the order of elements changes all the time. This means there is an additional step when you commit: Check for any modified settings and handle them, first.
It also means that the whole team has to agree on some standards: Like which warnings should be enabled. It's interesting that many people see this as a additional problem - as if they weren't working together.
In my experience, it takes a couple of weeks until those files stabilize. Partly because you gradually learn how to tweak Eclipse, partly because people learn what not to touch. You can think of this as lost time or time spent to improve the quality of your work environment (like keeping your desk uncluttered).
There is a bonus advantage of the "Commit settings first": It gets people to commit more often and in smaller pieces (i.e. more like "one thought at a time" instead of "on feature at a time plus a thousand of other, unrelated things that I just happened to stumble upton ... what was I working on again?").
As a seasoned developer, I've come to prefer the "small commits" way of working; it's just easier to stay on track and you tend to sort your thoughts and changes into smaller, more manageable steps. This helps to reduce the level of complexity. Everyone can juggle with one ball, no one can juggle with 20.
PS: For certain setting files, I have unit tests to make sure known errors don't creep in like the "trying to deploy tests" in WTP. That helps in the initial phase "commit everything, I'm too busy" phase.