You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Daniele Dellafiore <il...@gmail.com> on 2007/12/15 12:23:32 UTC

Multi module best practice and folder layout.

Hi all.

I have just finished to set up a multi-module project. The main
project artifactId is "arte". A lot of the dependency are my own
project so I wanted to have them listed as modules, mainly to obtain
the result that Eclipse project of arte is created referencing the
submodules project rather than the jars.
Now to accomplish this I have the pom.xml for arte, with packaging=jar
and in onother folder I have the multi-module pom, call it arte-super
that contains the multi-module specifications:

   <modules>
      <module>../parent</module>
      <module>../jin-collections</module>
      <module>../stuff</module>
      <module>../jocker</module>
       [...]
   </modules>

I have used the so called flat project layout
(http://maven.apache.org/plugins/maven-eclipse-plugin/reactor.html)

Everything works. If I go in arte-super folder and write "mvn
eclipse:eclipse" the arte eclipse project is created the way I desire.
If I write "mvn install" all the packages in the modules are
installed. Very good.

I am wondering about two marginal things but you know, when you start
to seriously automate your project, tendency is to have a real clean
environment that allow the better comprehension of the whole.

First: the arte-super is a "parent" module? I mean, I use parent when
I want to use pom inheritance. When I have a pom packaged project that
just have modules definition, like arte-super, is it a parent project?
It seems to me that targets are different.
A parent project contains some commons definition like developers,
url, distribution-management, repositories and such.
The super project contains modules definition. They just share the
packaging=pom.
Maybe is just a detail, but I think is important to clarify the intent
and scope of every aspect of project comprehension.

Again, the folder layout for parent and super project. I have a flat
layout, so arte and arte-super as well as a common parent project for
many of my modules are in the same folder.
What I am thinking is that if a parent project should really stay
there, the super project should stay in a sub folder of the "buddy"
project. To explain: arte-super should stay in a subfolder of arte.
This is because they are intimate connected, they should stay under
the same SCM folder and be checked out together. Then you can choose
to use the super project or not,  but you have the choice.

OK, these are my waken-up-too-early Saturday morning thoughts. I know
they sound a little maniacal but I really believe that giving a
concrete a precise meaning to things (parent/super) and standardize
every aspect of a complex project is really useful.

Have a good saturday :)

-- 
Daniele Dellafiore
http://ildella.wordpress.com/

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


Re: Multi module best practice and folder layout.

Posted by nicolas de loof <ni...@apache.org>.
Maven2 both support the notion of parent and modules.
in many case the same POM can be used as parent AND as multi-module, but
this is not required.

To avoid confusion, you can name your "super" project "arte-project" so that
is does not use the parent-child vocabulary and only serve as
shared-infrastructure for your modules.

In many cases, as you noticed, the parent-POM is used to share metat-datas.
I myslef use this hierarchy :

corporate POM
[ defines repositories, CI management, SCM ... ]

-> project POM
    [ defines dependencies versions in dependencyManagement, developers,
project target JRE ... ]

   -> module POM
       [ define local dependencies and build ]

The corpoeate POM does not list all projects as modules. It has its own
lifecycle
The project POM list modules, and is used to build the whole project in one
command

This demonstrates well the distinction :
- a project with <parent> is part of it's parent "domain" and inherits
configuration
- a POM with <module> only groups a set of projects that are related and
SHOULD build together

If you created your arte-super JUST to get eclipse project references (and
not jars references) BUT your other modules have an independant lifecycle,
I'll consider this to be a pragmatic solution, but not the cleanest one.
If your project uses commons-lang and you have checked it out from
svn.apache.org as a project in eclipse, would you add commons-lang as a
module in arte-super, just to make eclipse:eclipse work as you want ?

The "clean" way is to wait for http://jira.codehaus.org/browse/MECLIPSE-344 to
get fixed !

... but until this is done, your arte-super is the simpliest solution !

Nico.


2007/12/15, Daniele Dellafiore <il...@gmail.com>:
>
> Hi all.
>
> I have just finished to set up a multi-module project. The main
> project artifactId is "arte". A lot of the dependency are my own
> project so I wanted to have them listed as modules, mainly to obtain
> the result that Eclipse project of arte is created referencing the
> submodules project rather than the jars.
> Now to accomplish this I have the pom.xml for arte, with packaging=jar
> and in onother folder I have the multi-module pom, call it arte-super
> that contains the multi-module specifications:
>
>   <modules>
>      <module>../parent</module>
>      <module>../jin-collections</module>
>      <module>../stuff</module>
>      <module>../jocker</module>
>       [...]
>   </modules>
>
> I have used the so called flat project layout
> (http://maven.apache.org/plugins/maven-eclipse-plugin/reactor.html)
>
> Everything works. If I go in arte-super folder and write "mvn
> eclipse:eclipse" the arte eclipse project is created the way I desire.
> If I write "mvn install" all the packages in the modules are
> installed. Very good.
>
> I am wondering about two marginal things but you know, when you start
> to seriously automate your project, tendency is to have a real clean
> environment that allow the better comprehension of the whole.
>
> First: the arte-super is a "parent" module? I mean, I use parent when
> I want to use pom inheritance. When I have a pom packaged project that
> just have modules definition, like arte-super, is it a parent project?
> It seems to me that targets are different.
> A parent project contains some commons definition like developers,
> url, distribution-management, repositories and such.
> The super project contains modules definition. They just share the
> packaging=pom.
> Maybe is just a detail, but I think is important to clarify the intent
> and scope of every aspect of project comprehension.
>
> Again, the folder layout for parent and super project. I have a flat
> layout, so arte and arte-super as well as a common parent project for
> many of my modules are in the same folder.
> What I am thinking is that if a parent project should really stay
> there, the super project should stay in a sub folder of the "buddy"
> project. To explain: arte-super should stay in a subfolder of arte.
> This is because they are intimate connected, they should stay under
> the same SCM folder and be checked out together. Then you can choose
> to use the super project or not,  but you have the choice.
>
> OK, these are my waken-up-too-early Saturday morning thoughts. I know
> they sound a little maniacal but I really believe that giving a
> concrete a precise meaning to things (parent/super) and standardize
> every aspect of a complex project is really useful.
>
> Have a good saturday :)
>
> --
> Daniele Dellafiore
> http://ildella.wordpress.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>