views:

46

answers:

2
+1  Q: 

Working with Maven

I downloaded Java source code of some project that works with Maven. After checking out the code to Eclipse, and then building it from the command line, I followed the instructions and imported it from Eclipse as: File > Import > Maven Projects. Now I have the core source code and many additional sub projects that seem to have the same thing like the core, just separated.

Could anyone please explain me what are these sub projects? why I need them? and on which code I need to work now if I want to make changes, the core or the new imported Maven ones?

I don't know nothing about Maven besides the fact that it's a tool for building code and managing releases.

Thanks!

+2  A: 

In Maven land, these are called modules. There a nice way to further divide a project into very distinct pieces.

People handle Maven differently. I've seen projects where there was the actual project module, then 10 or so implementation modules. Most people use them for the above mentioned separation.

Most likely, your going to need all of the modules in order to work correctly.

To modify the project, your going to need Maven. I don't know if Eclipse has an embedded maven, but at least NetBeans does. With this you can modify anything that you want, then build it with Maven, which should be just a simple click.

TheLQ
I see, Thanks! one more question.. so now I don't need the initial source code? means, the code before I imported the Maven modules; should I only work on the Maven modules now?Thanks again.
@user247866 The Maven project (should) include everything from the source to the build jars, including the Maven module. So yes, you do need everything
TheLQ
+2  A: 

In addition to what @Quackstar said:

Eclipse has embedded Maven support provided by the m2eclipse plugin. When you import a Maven project consisting of multiple modules, the default behavior is to map each Maven module as a separate Eclipse project. This allows the Eclipse build paths to be constructed in a way that matches the declared Maven module dependencies.

There is also a way to map a multi-module Maven project into a single Eclipse project that entails enabling m2eclipse's "Nested Module" support. This results in an Eclipse project with a build path that is an amalgam of all of the Maven module dependencies ... and not exactly correct. This approach is not recommended by the m2eclipse developers, and I've heard they are intending to remove the nested module feature entirely in a future release.

Stephen C
Yes, I'm using m2eclipse. For me it's all new, I always work with only one eclipse project, even if I have many files. Now I have lots of projects that are related to each other, and it's a bit confusing. Thanks for your answer!
Huh. I would of thought Eclipse had the project layout like IDEA does (1 project -> multiple modules). Anyway thanks for added info, I didn't know that since I'm a netbeans guy
TheLQ
Eclipse does not have a 'module' concept, and doesn't allow projects to be nested.
Stephen C