Home » Newcomers » Newcomers » Hierarhical organization of projects(Is there any possibility?)
Hierarhical organization of projects [message #1508413] |
Fri, 12 December 2014 06:41  |
Eclipse User |
|
|
|
Hello! I'm new in Eclipse, and I wonder if there is any possibility to organize projects hierarchically, so that a folder might contain individual projects and folders containing other folders and projects? I think it would be a useful and important feature, and it seems rather strange, but I can not find a way to do so.
|
|
| | | |
Re: Hierarhical organization of projects [message #1508582 is a reply to message #1508510] |
Fri, 12 December 2014 09:34   |
Eclipse User |
|
|
|
Michail Vokhm wrote on Fri, 12 December 2014 13:26Te issue also relates to package structures. If I have packages org.domain.pack1 and org.domain.pack2, I expect to find their respective files in folders someplace/org/domain/pack1, someplace/org/domain/pack2, but not in workspace/project1/org/domain/pack1, workspace/project2/org/domain/pack1. Why do I have to duplicate the same subfolder structure in separate project folders to hold related projects? What is the right way to avoid this? There would be a workaround if I could make the Eclipse to discover package names in the java files located in the subfolders, and to show these packages and respective java files in the package explorer; but how can I do it?
It's not clear what you're trying to achieve. Package names are really not hierarchical, they just appear to be because of the dot-based naming convention and because virtually every tool presents them as hierarchical.
Having said that, if the two packages org.domain.pack1 and org.domain.pack2 are part of separate projects, I don't see why you'd expect their files to be mixed together in one folder (logical or physical). If they're part of separate projects, they're in separate folders.
Can you explain in more detail what you're trying to achieve?
|
|
|
Re: Hierarhical organization of projects [message #1508701 is a reply to message #1508582] |
Fri, 12 December 2014 11:40   |
Eclipse User |
|
|
|
Well, for example, I have standard swt examples which form packages:
package org.eclipse.swt.examples.texteditor;
package org.eclipse.swt.examples.accessibility
etc.
Their sources (as they are given) are organized in folders like
org/
eclipse/
swt/
examples/
accessibility/
texteditor/
etc.../
I would like to keep them on their places, in the example folder, yet to be able to compile them and otherwise play with them. If i place the whole tree in the workspace and then import each of them like a separate project, i get something like
workspace/
org/
eclipse/
swt/
examples/
accessibility/ /// was pointed to as a project location
org/ /// From this point, built by
/// Eclipse according to package name
eclipse/
swt/
examples/
accessibility/ ;
org/
eclipse/
swt/
examples/
texteditor/ /// was pointed to as a project location
org/ /// From this point, built by
/// Eclipse according to package name
eclipse/
swt/
examples/
texteditor/ ;
....
And I have a dozen of projects in the workspace.
I definitely dislike this.
I would prefer to keep them all as subfolders of a single folder that traditonally reflects the package names, as they are placed in the jar; and I would like to see them as subbranches of a single tree in the package explorer and project explorer.
As I mentioned, there could be a workaround if I could make Eclipse to see (and show in the package explorer) all the packages in the subfolders within a single project (say, "SWTExamples"), but it can see nothing located in the subfolders unless I "import" a contents of a subfolder as a separate project.
So, if Eclipse can not maintain an hierarchical structure of projects, there will be another question: how do I make it see packages in subfolders when I just put a folder with subfolders in its workspace? When I create a project with a few packages in it, it makes a folder in the workspace and builds subfolders for these packages and can see these packages afterwards, but when I create a similar directory structure manually (or take it somewhere else) - Eclipse can see nothing in such a directory. Why is this? What is the difference between my own handmade folder with subfolders with java files, and a folder with subfolders with java files, made by Eclipse?
|
|
| |
Re: Hierarhical organization of projects [message #1514671 is a reply to message #1508724] |
Wed, 17 December 2014 08:50   |
Eclipse User |
|
|
|
I still don't understand what you're trying to achieve; is it that you want a separate project, for example, for the "accessibility" and the "texteditor" examples? That's possible, but only as separate source trees. If you want to keep them in their existing location, where the packages are rooted under a common folder, then they'd have to be single (logical) Project in Eclipse.
A few things that you might not be aware of:
1) The Eclipse workspace is primarily a logical container, but can also be a physical container, of projects. That means that projects and their files can be stored outside of the workspace directory on your file system. In fact this is quite common and encouraged. It's unfortunate, in my opinion, that the default location when creating a new project is in the workspace directory.
2) Eclipse has the notion of "source locations" in every Java project, and there can be more than one and they are totally configurable by the user. The default is /src under the project root, and if you import or create code files without otherwise configuring your project, that's where they will go.
3) Eclipse enforces that the directory structure to contain .java files exactly match the package structure declared in the code. This isn't a hard requirement of the JDK, but is a universal "best-practice" that Eclipse enforces. This is the primary reason why Eclipse does not (can not) allow source locations to be nested inside other source locations, because doing so would violate this rule.
If you open the Eclipse Help Contents and navigate to "Java development user guide" > Getting Started > Project Configuration Tutorial, you might gain some more understanding of this stuff. Maybe that will help you get close to what you're trying to achieve.
[Updated on: Wed, 17 December 2014 08:53] by Moderator
|
|
| |
Goto Forum:
Current Time: Mon Jul 07 09:08:36 EDT 2025
Powered by FUDForum. Page generated in 0.57850 seconds
|