user1888243
user1888243

Reputation: 2691

Eclipse:How to Detect a Project is Part of the Workspace

How can I make sure a project that is shown in my workspace is actually part of the workspace. Below, I will explain what happened so that you know why I'm asking this question.

I had checked out a project into my workspace, and then had configured it as a Maven project by selecting Configure->Convert to Maven Project; in most cases, when I do this, the project becomes part of the workspace. But in this case it hadn't. But I spent a few hours before realizing that I need to import the project in order for the workspace to recognize it as workspace project. So, I want to avoid this situation and be able to look at a flag or file or something that tells me if a project that is shown in the Eclipse window is actually a workspace project.

Thanks

I'm adding the following to make the problem more clear:

This is what I do; I have a workspace with a few projects (all Java/Maven project); everything works. Then I checkout another project from svn into the workspace; so, the folder of the new project is within the same workspace. I expected that as soon as I check out the new project into the workspace, and convert the new project into a Maven project, then the new project be recognized by Eclipse as one of the projects in the workspace. But that is not the case; I actually have to import it.

The project folder is there, and I can see it in the Project explorer. Nothing happens to it, but it is not used by the workspace. For example, if I add breakpoints to the Java files which are in the new project, they are not used. At this point, I use File->Import menu to import the project from the same folder that is already in the workspace, and bang, it starts working, and my breakpoints work.

Is my procedure for checking out a project from SVN into the workspace wrong? I want to fix my procedure to make sure this will never happen. Do you think that even though the new project is a subfolder of workspace, I should still need to import the project into the workspace?


I just noted another fact; this particular project that I'm importing is a Maven multi-module; could it be that the parent project is actually part of the workspace, but the modules inside it are not; therefore, just because it is a Maven multi-module, I need to import the sub-modules.

Upvotes: 0

Views: 1403

Answers (2)

Basilevs
Basilevs

Reputation: 23958

There are four ways to create a project in Eclipse:

  • create
    • Create in a default location (workspace folder on a filesystem)
    • Create in user-specified location (anywhere)
  • import
    • Project is referenced from workspace, untouched otherwise, location on a filesystem is unchanged
    • Project is copied into default location

You probably want to know if a project is located in workspace folder on filesystem. To do this, you can open project's properties and find location in resource node:

location of resource in project's properties

Upvotes: 1

arcy
arcy

Reputation: 13153

"... in order for the workspace to recognize it as a workspace project..." doesn't make any sense to me. I'm not exactly an eclipse expert, but a workspace is the set of directories in which you are working at one time in eclipse. There can be more than one workspace for eclipse on a given machine.

If you checked it out and it appeared in eclipse, then it was "in the workspace" afaik. Now, Maven tasks create and change files, and those changes do not automatically show up in the workspace -- you have to refresh the project, which essentially syncs the filespace with the workspace.

If that doesn't cover your case, then detail what you mean by "not in the workspace".

Upvotes: 0

Related Questions