Existing Package Hierarchy [message #192177] |
Tue, 06 February 2007 10:23  |
Eclipse User |
|
|
|
Originally posted by: eclipse_newsgroup.lizakowski.com
I have *all* of my java source organized neatly into one package
hierarchy, and I want to use Eclipse. I tried using eclipse back in
version 2.x, but it was not able to work with files in this layout. Is
there a solution for 3.x?
Below is an example of my hierarchy - it is actually much larger. It
contains both libraries and applications, and there are dependancies
amongst them. This makes for good code re-use. All java sources are in
packages. I just set my classpath to the location of /com and life is
good.
What I want to do is tell Eclipse two things:
1) The location of the root of the tree (my classpath)
2) The subdirectory where I want to build an application
(The project file would go here)
With these two pieces of information, I want to build in the target
directory, but be able to edit other files in the hierarchy if needed.
This way, I can develop an application and create a corresponding library
at the same time.
What do I do? How can I edit these files in eclipse?
com
xyz
tools
sql
html
pdf
xml
apps
app1
app2
web
webapp1
webapp2
|
|
|
|
|
Re: Existing Package Hierarchy [message #192949 is a reply to message #192177] |
Thu, 08 February 2007 16:57   |
Eclipse User |
|
|
|
Originally posted by: eclipse5.rizzoweb.com
Jeremy wrote:
>
> I have *all* of my java source organized neatly into one package
> hierarchy, and I want to use Eclipse. I tried using eclipse back in
> version 2.x, but it was not able to work with files in this layout. Is
> there a solution for 3.x?
>
> Below is an example of my hierarchy - it is actually much larger. It
> contains both libraries and applications, and there are dependancies
> amongst them. This makes for good code re-use. All java sources are in
> packages. I just set my classpath to the location of /com and life is
> good.
>
> What I want to do is tell Eclipse two things:
> 1) The location of the root of the tree (my classpath)
> 2) The subdirectory where I want to build an application
> (The project file would go here)
>
> With these two pieces of information, I want to build in the target
> directory, but be able to edit other files in the hierarchy if needed.
> This way, I can develop an application and create a corresponding
> library at the same time.
> What do I do? How can I edit these files in eclipse?
> com
> xyz
> tools
> sql
> html
> pdf
> xml
> apps
> app1
> app2
> web
> webapp1
> webapp2
OK, there are a couple of different ways to go here. I'll try to point
out a general recommendation based on years of experience and then turn
around and talk about leaving it alone and working with what you have
as-is in Eclipse.
First, I'd recommend splitting things up into different projects, rather
than having it all rooted at one spot. For one reason, it is easier to
manage smaller modules than a monolithic code base. How do you write
build scripts when it is monolithic? How to you handle version control
of the tools stuff (for example if app1 needs a certain version of sql
package but app2 needs another)? Generally speaking, smaller projects
(to a certain point, of course) make for easier management.
So, I would go that route instead of trying to keep it all under one
root. Build JARs for the reusable packages like sql and xml, and then
the apps can depend on the JARs rather than the source directly. I am
doing this very thing currently on a project I manage, and it is nice to
be able to mange the low-level stuff separately. My app build actually
knows how to call into the util project to do builds of it, but they are
in different projects.
Now, if you choose to ignore that advice (which you are free to do, of
course), you can still work with it in Eclipse, although it might be
more trouble than it is worth.
One of the things your going to bump your head against is that Eclipse
will not let you have Project content directories overlap each other or
be rooted at the same place. Naively, you might think that means you can
only have one monolithic Eclipse Project. That is not necessarily true,
although it might turn out that way depending on how you want to work.
One Eclipse feature that might help you is Linked Resources (search the
Eclipse Help Contents for that phrase for all the details). In short,
you can create a link from a project to an arbitrary directory on your
file system, and Eclipse will treat that as if it was part of your
Project contents. So you could create several projects (one for each
app) and link them all to the same root of your source tree. Combined
with the ability to define inclusions and exclusions of the project
source locations (to include/exclude various packages), you could get
each app project set up to only include the parts of the source tree it
needs.
It is hard to give more detailed help without diving in and trying it
out on your particular setup. So have a go with this info, and feel free
to post back with any specific questions.
Keep in mind, however, that my recommendation to break up the source
tree into at least one "Tools" project and one project for each app, is
a STRONG recommendation. It is based on working on dozens of different
code bases and projects. So please give it serious consideration. Even
if you get the alternative working in Eclipse, there is a good chance
something will be a PITA at some point with that set-up.
Hope this helps,
Eric
|
|
|
|
Powered by
FUDForum. Page generated in 0.31795 seconds