You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Alan Kent <AL...@saic.com> on 2007/07/04 13:48:13 UTC

Using Maven with Eclipse well: mvn eclipse:eclipse and nested projects

I have a multi-module project and I am trying to get the "right" set up 
to use Maven with Eclipse.  I have a question below on mvn 
eclipse:eclipse, but some background first.

I used to use m2eclipse with Eclipse 3.1 but as the projects have grown, 
m2eclipse has shown to have problems.  For example in a multi-module 
project, each module might want different versions of a jar file in the 
path (say in different WAR files).  m2eclipse seems to load all the 
different source directories up into one mega-project, and come up with 
a single list of all dependencies flattened across projects.  When 
m2eclipse worked, I sometimes got different versions of artifacts in the 
dependency list.  Frequently it just refused to work, not finding all 
the dependencies correctly - which is probably a bug.  However 
regardless of any possible bugs, the basic premise seems wrong - each 
module should have its own dependencies worked out as they may *want* 
different versions of jar files.

mvn eclipse:eclipse therefore looks a better way to go.  I can check out 
a SVN tree, run mvn eclipse:eclipse, then load up all the modules as 
separate projects with only the jar file dependencies for that module 
included.  This works much more reliably - no problems so far.

However, because it creates a project per module, I cannot use the 
global Eclipse SVN support for tagging, branching, switching etc.  I 
cannot do this from the top of the tree.  I have to go back to the 
command line.

I just downloaded Eclipse Europa (3.3) and it (as well as 3.2 I believe) 
supports nested projects.  That is, it appears I can have a .project 
file in the root directory plus one in each module directory.  (I am 
having a little trouble with Subclipse and Subversive, but I think they 
will be resolved so I am going to assume they work.)  This looks almost 
ideal, which leads me to finally to my question...

Q: Is there any way to make "mvn eclipse:elipse" generate a .project 
file for the root directory as well as each module?  That way I can 
check out the whole project tree from the root and have a project per 
pom file.  Eclipse can now handle nested projects, so it will load them 
all up (it used to refuse to load up child directory projects under a 
parent directory project).  I saw a hack somewhere of changing the root 
pom file to temporarily use "jar" packaging, then put it back to "pom" 
packaging - but this is pretty ugly.  Now that Eclipse supports nested 
projects, is there any reason not to do this?  It would give me the 
ability to do all the svn commands from inside Eclipse from the root 
package (I don't need or want to compile any Java code from the root 
package - I just want to be able to explore the tree, do 'sync with 
repository', commits, svn switches etc) plus each module would get its 
own correct dependency list as occurs now.  I would do all compiles in 
the module directories.

Is this possible now?  (I don't think so.)  Can it be added?  Would it 
allow what I am trying to do?

Thanks!
Alan Kent

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Using Maven with Eclipse well: mvn eclipse:eclipse and nested projects

Posted by Greg Thompson <th...@credentica.com>.
Alan Kent wrote:
> Q: Is there any way to make "mvn eclipse:elipse" generate a .project 
> file for the root directory as well as each module?  That way I can 
> check out the whole project tree from the root and have a project per 
> pom file.

Not that I know of, but this works for me:

1. Check out the parent module into your workspace.

2. "mvn eclipse:eclipse" to create the various .project and .classpath
    files in the sub-modules.

3. Switch to the Java perspective in Eclipse.

4. Select the parent module and hit F5 to refresh (just for grins).

5. Choose "File->Import...", "Existing Projects into Workspace", and
    browse in your workspace into your parent module.

6. Select one of the sub-modules, make sure "Copy projects into
    workspace" is /not/ checked, and hit "Finish".

7. Lather, rinse, and repeat steps 5 and 6 with the other submodules.

In this way, you can do all of your SCM in Eclipse via the parent 
module, yet play with the submodules as proper Java projects.

As far as I know, this is the "recommended" way to develop a 
multi-module project with Eclipse.  Someone please correct me if I'm wrong.
-- 
		-Greg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org