views:

584

answers:

2

I like Eclipse and I want to use it, the problem is that I can't figure out a simple and fast way to configure projects once checked out from svn.

All projects I work with have several modules and are configured with a top folder which contains four folders: the build output, libs, main and profiles.

In detail:

  • libs contains compile libs, test libs and normal usage libs.
  • main contains three folders: java (for sources), resources (for things like ibatis xml) and webcontent (for jsps, css, js, imgs and the like)
  • profiles contains three folders: personal, test and production which are added to the build depending on the target environment.

How can I achieve this using Eclipse? This is the only thing I dislike of this ide, I've always found difficult to configure a project the way I want (and not the way it wants :P)

I was always told that Eclipse uses a very strict structure for its projects, but I can't believe there is no solution and I just have to stick with Idea. I want to work with something I like, I think this is fundamental.

Also, do you think this is a good configuration for a project? What if I just change it to my needs with a script that rearranges the structure after svn checkout? Will I have problems when committing files to svn this way? I don't want to change everyone's structure on svn.

+2  A: 

There are definitely come constraints in an Eclipse workspace but it is quite flexible (with linked folder and include/exclude support). There are some detailed examples in the project configuration tutorial.

If I understand the layout correctly I think you do not have to change this structure (at least for the sources). You can create a bunch of java projects and/or dynamic web projects (latter for web "modules"), one per module (you should treat an Idea project as an Eclipse workspace and a module as an Eclipse project). You can set webcontent as the content directory, main/java and main/resources as java source folders and you can add the jars from libs to the build path (or simply put them in the webcontent/WEB-INF/lib directory).

The most complicated stuff is the profiles and the compile/test/normal libraries. I would put the normal and compile libs to the build path of the project and add the test libs explicitly to the classpath of a test run configuration. For the profile I do not know a simple method - maybe a fourth linked folder which always map the one actually used...

The Idea migration faq can also help to summarize some key differences between the two ide.

Csaba_H
Thanks for the answer, I did not know about linked folder.
Alberto Zaccagni
A: 

If understand you correctly you can "import" the project by creating a new one.

  1. File -> New -> Java Project
  2. Select "Create Project from existing source" and Browse to your project-directory
  3. Click next in order to see if Eclipse has got it the way you want it

Usually Eclipse does a nice job on detecting you project layout, so this should do this. Additionally, like Csaba_H said, you might have to adapt the project for the testing stuff.

Another solution would be migrating this project to a build system like Apache Maven 2 (I know that it is a project management tool ;)). All modern IDE's (Eclipse only with 3rd party plug-ins M2Eclipse or Q for Eclipse) support importing Maven projects directly so you do not have to adapt anything. Additional Maven has a dependency management which takes care of download dependencies, adding them to the correct classpath, depending on the scope (compile, test, runtime). Maven usually follows the "Convention over configuration"-rules and so it defines a standard path for your java/test classes/resources, but you can configure them to your layout if you want to. If you chose to give it a try you should check out the free book Maven: The Definitive Guide

Roland Schneider
I have say... 10 projects at least and none of them uses Maven :P I will not configure each one with Maven, I'll never obtain the time to do this.
Alberto Zaccagni