Skip to main content



      Home
Home » Newcomers » Newcomers » Structure of Projects - Can I have a Sub Project?
Structure of Projects - Can I have a Sub Project? [message #265642] Fri, 17 October 2008 10:56 Go to next message
Eclipse UserFriend
Hi,

I am new to eclipse and am having trouble working out how I should
structure my project.

I have an existing java code base that has a src directory, containing
java source files, an obj directory which is where I have currently been
getting javac to place the .class files and a tests directory that
contains several subdirectories, each containing a small java program. The
code in src builds into a library and the programs in tests exercise this
library in various ways.

The way I have imagined it working in eclipse is the whole lot is one
project with multiple targets. The library, built from src, is a target
(producing a jar file) and each test program in tests is a target that
just has the jar file made earlier in its class path. Is this the Eclipse
way of thinking?

If I modify a source file that goes into the making of the library and
then try and run a test program the library needs to be rebuilt. If I use
the debugger on a test program I want to be able to step into the library.

I have been playing around with Project properties etc and I can't seem to
work out how I would create such a setup. I can just hand build ant files
to do it and get Eclipse to call those but that seems to defeat the
purpose of me using an IDE.

Thanks,

Andrew
Re: Structure of Projects - Can I have a Sub Project? [message #265649 is a reply to message #265642] Fri, 17 October 2008 20:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cboe.news.eclipse.org

On Fri, 2008-10-17 at 14:56 +0000, Andrew wrote:
> Hi,
>
> I am new to eclipse and am having trouble working out how I should
> structure my project.
>
> I have an existing java code base that has a src directory, containing
> java source files, an obj directory which is where I have currently been
> getting javac to place the .class files and a tests directory that
> contains several subdirectories, each containing a small java program. The
> code in src builds into a library and the programs in tests exercise this
> library in various ways.
>
> The way I have imagined it working in eclipse is the whole lot is one
> project with multiple targets. The library, built from src, is a target
> (producing a jar file) and each test program in tests is a target that
> just has the jar file made earlier in its class path. Is this the Eclipse
> way of thinking?
>
First take a look at the Product Configuration Tutorial in the Java
Development Users Guide. Here is the online URL:
http://help.eclipse.org/ganymede/topic/org.eclipse.jdt.doc.u ser/gettingStarted/qs-ProjectConfiguration.htm

Eclipse doesn't really have a concept of targets. You should be able to
do what you want with a single project. Define the src and tests
directories as source folders and the obj directory as an output folder.
Eclipse will then compile all of the source (both src and tests) for
you.

You can run each of your tests separately by creating a launch
configuration for each one. The short cut to create a launch is to
select the runnable class (any class with a public static main method),
right click, and select Run as->Java Application from the context menu.

You can edit program arguments from the Run->Run Configurations dialog.
Use the Debug menu to run in debug mode.

> If I modify a source file that goes into the making of the library and
> then try and run a test program the library needs to be rebuilt. If I use
> the debugger on a test program I want to be able to step into the library.
>
> I have been playing around with Project properties etc and I can't seem to
> work out how I would create such a setup. I can just hand build ant files
> to do it and get Eclipse to call those but that seems to defeat the
> purpose of me using an IDE.
>
> Thanks,
>
> Andrew
>
Re: Structure of Projects - Can I have a Sub Project? [message #265667 is a reply to message #265649] Mon, 20 October 2008 09:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

On 10/17/2008 8:53 PM, David Wegener wrote:
> On Fri, 2008-10-17 at 14:56 +0000, Andrew wrote:
>> Hi,
>>
>> I am new to eclipse and am having trouble working out how I should
>> structure my project.
>>
>> I have an existing java code base that has a src directory, containing
>> java source files, an obj directory which is where I have currently been
>> getting javac to place the .class files and a tests directory that
>> contains several subdirectories, each containing a small java program. The
>> code in src builds into a library and the programs in tests exercise this
>> library in various ways.
>>
>> The way I have imagined it working in eclipse is the whole lot is one
>> project with multiple targets. The library, built from src, is a target
>> (producing a jar file) and each test program in tests is a target that
>> just has the jar file made earlier in its class path. Is this the Eclipse
>> way of thinking?
>>
> First take a look at the Product Configuration Tutorial in the Java
> Development Users Guide. Here is the online URL:
> http://help.eclipse.org/ganymede/topic/org.eclipse.jdt.doc.u ser/gettingStarted/qs-ProjectConfiguration.htm
>
> Eclipse doesn't really have a concept of targets. You should be able to
> do what you want with a single project. Define the src and tests
> directories as source folders and the obj directory as an output folder.
> Eclipse will then compile all of the source (both src and tests) for
> you.
>
> You can run each of your tests separately by creating a launch
> configuration for each one. The short cut to create a launch is to
> select the runnable class (any class with a public static main method),
> right click, and select Run as->Java Application from the context menu.

Also, if your tests are JUnit tests you can right-click on the class (or
package or project) and choose Run As... > JUnit Test and it will run
the tests.

Hope this helps,
Eric


> You can edit program arguments from the Run->Run Configurations dialog.
> Use the Debug menu to run in debug mode.
>
>> If I modify a source file that goes into the making of the library and
>> then try and run a test program the library needs to be rebuilt. If I use
>> the debugger on a test program I want to be able to step into the library.
>>
>> I have been playing around with Project properties etc and I can't seem to
>> work out how I would create such a setup. I can just hand build ant files
>> to do it and get Eclipse to call those but that seems to defeat the
>> purpose of me using an IDE.
>>
>> Thanks,
>>
>> Andrew
>>
>
Re: Structure of Projects - Can I have a Sub Project? [message #265721 is a reply to message #265649] Wed, 22 October 2008 14:08 Go to previous message
Eclipse UserFriend
Thanks, I think I have things working now. "linking" the source in for
each test, and the actual library source, was the trick.

Thanks,

Andrew
Previous Topic:Help plugin content is cached, can't see changes
Next Topic:eclipse through ssh tunnel on linux
Goto Forum:
  


Current Time: Tue Jul 22 15:31:06 EDT 2025

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

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

Back to the top