Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Source Dir Structure for Common Packages
Source Dir Structure for Common Packages [message #168685] Thu, 31 August 2006 14:56 Go to next message
Eclipse UserFriend
Originally posted by: steve.kincer.org

It seems that out of the box, eclipse expects you to put your souce in a dir
under the project folder. So, if my proj is called MyProj and my pkg is
com.mycompany.mypkg, the dir would be:

MyWorkspace\MyProj\com\mycompany\mypkg

I like to use certain common packages in a many projects that I do, so this
seems like a problem. For example, if I have a package called
com.mycompany.utils, I want to be able to import that in any other source
files as

import com.mycompany.utils.*;

I feel like I must be missing something in terms of how others structure
their development environment. It seems like everyone would want the source
root to be the same directory for every project they work on, and then have
the source for various projects/packages all have the same starting point.
How do others structure their source dirs when you have packages that you
use in many different projects?
Thanks.
Steve
Re: Source Dir Structure for Common Packages [message #168732 is a reply to message #168685] Thu, 31 August 2006 16:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jefmyers.us.ibm.com

Steve,

Usually you'd move the common packages to its own project, then add that
project to the Java build path for all of the projects that use it.

This help topic may be useful in deciding what project structure you
want to use:
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. jdt.doc.user/gettingStarted/qs-ProjectConfiguration.htm

Hope this helps,
- Jeff
Re: Source Dir Structure for Common Packages [message #169155 is a reply to message #168685] Mon, 04 September 2006 03:28 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse4.rizzoweb.com

Steve Kincer wrote:
> It seems that out of the box, eclipse expects you to put your souce in a dir
> under the project folder. So, if my proj is called MyProj and my pkg is
> com.mycompany.mypkg, the dir would be:
>
> MyWorkspace\MyProj\com\mycompany\mypkg
>
> I like to use certain common packages in a many projects that I do, so this
> seems like a problem. For example, if I have a package called
> com.mycompany.utils, I want to be able to import that in any other source
> files as
>
> import com.mycompany.utils.*;
>
> I feel like I must be missing something in terms of how others structure
> their development environment. It seems like everyone would want the source
> root to be the same directory for every project they work on, and then have
> the source for various projects/packages all have the same starting point.
> How do others structure their source dirs when you have packages that you
> use in many different projects?

Two reasonable options that I see:
1: (most preferable) Put the common code into its own project (eg,
called Common) and then have other projects depend on that one when they
need its classes.
2: Any project can define however many source root folders as it wants,
and they don't have to be right below the project root. So you can copy
your common code into the other project(s) in a different source
location. Edit your project's properties and select the Java Build Path
section to see the Source locations tab.

I, personally, use the first approach; furthermore, I always have a
"source" directory in my projects (and sometimes a "java" directory
under that) where my package name structure starts. Like this:

MyProject/
build/
<this is my build output location>
lib/
<compile-time JAR files live here>
source/
java/
<package structure starts here,
<with .java files placed appropriately>
web/
<if needed>
someOtherKindOfSource/
<if needed>




Hope this helps,
Eric
Previous Topic:Database development tools command error
Next Topic:Why Use SWT over Swing
Goto Forum:
  


Current Time: Thu Mar 28 12:24:35 GMT 2024

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

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

Back to the top