Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Existing Package Hierarchy
Existing Package Hierarchy [message #192177] Tue, 06 February 2007 15:23 Go to next message
Eclipse UserFriend
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 #192856 is a reply to message #192177] Thu, 08 February 2007 20:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

Ian Bull wrote:
> In order to use your existing hierarchies / java applications in Eclipse
> you have to import them into Eclipse projects. Eclipse does not support
> the idea of "pointing it to an existing directory".

Strictly speaking, that is not true. When creating a Project in Eclipse,
you have the option of specifying an existing file structure as its
location and Eclipse will use the files that are there. It might require
configuring the Project Build Path settings to tell it where the source
root and dependent JARs are, but that is a common way to work.

Hope this helps,
Eric
Re: Existing Package Hierarchy [message #192888 is a reply to message #192856] Thu, 08 February 2007 21:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

Really, I have never done this. You learn something new every day!
Thanks Eric!

cheers,
ian

Eric Rizzo wrote:
> Ian Bull wrote:
>> In order to use your existing hierarchies / java applications in
>> Eclipse you have to import them into Eclipse projects. Eclipse does
>> not support the idea of "pointing it to an existing directory".
>
> Strictly speaking, that is not true. When creating a Project in Eclipse,
> you have the option of specifying an existing file structure as its
> location and Eclipse will use the files that are there. It might require
> configuring the Project Build Path settings to tell it where the source
> root and dependent JARs are, but that is a common way to work.
>
> Hope this helps,
> Eric
Re: Existing Package Hierarchy [message #192949 is a reply to message #192177] Thu, 08 February 2007 21:57 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Existing Package Hierarchy [message #193936 is a reply to message #192949] Wed, 14 February 2007 06:16 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse_newsgroup.lizakowski.com

It's working - Thanks to all for the help!
Previous Topic:Need help
Next Topic:Setup
Goto Forum:
  


Current Time: Wed Apr 24 18:35:06 GMT 2024

Powered by FUDForum. Page generated in 0.07767 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top