You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by James Higginbotham <jh...@betweenmarkets.com> on 2004/02/13 20:58:24 UTC

Basic Maven Question - Dependencies

I've done some preliminary searching and reading of articles, docs, etc.
regarding Maven and multiple-subprojects, but haven't been able to
determine an answer to the following question: 

 

Assuming a project structure of:

 

Project

    |

    |--A

    |

    |--B

    |

    |--C

 

Where A depends upon B and C depends on A, the typical compile steps to
build the entire project would be B->A->C. I've seen articles regarding
the use of a reactor to provide a one-step method of making this compile
happen for all subprojects. However, our project has a large number of
modules and we'd like to build a subset of them for quicker testing
purposes by running Maven from, for example, subproject A (should build
and deploy only B and A, not C). This would prevent me from having to
compile all modules to simply test a set of 3 modules and deploy an EAR
with those components. Is this possible using typical Maven constructs?
What would be required to accomplish this using Maven? My first thought
is that each subproject A,B, and C would have its own project-level
Maven files as well as the master one that lives at the top level. Is
this the right approach? Anyone doing this? Any best practices suggested
with larger projects? 

 

Best Regards,

James

 


Re: Basic Maven Question - Dependencies

Posted by "Craig S. Cottingham" <cr...@cottingham.net>.
On Fri, 2004-02-13 at 13:58, James Higginbotham wrote:
> I've done some preliminary searching and reading of articles, docs, etc.
> regarding Maven and multiple-subprojects, but haven't been able to
> determine an answer to the following question: 
> 
> Assuming a project structure of:
> 
> Project
>     |
>     |--A
>     |
>     |--B
>     |
>     |--C
> 
> Where A depends upon B and C depends on A, the typical compile steps to
> build the entire project would be B->A->C. I've seen articles regarding
> the use of a reactor to provide a one-step method of making this compile
> happen for all subprojects.

Yes. The multiproject plugin does this beautifully.

> However, our project has a large number of
> modules and we'd like to build a subset of them for quicker testing
> purposes by running Maven from, for example, subproject A (should build
> and deploy only B and A, not C). This would prevent me from having to
> compile all modules to simply test a set of 3 modules and deploy an EAR
> with those components. Is this possible using typical Maven constructs?

Yes.

> What would be required to accomplish this using Maven?

See below.

> My first thought
> is that each subproject A,B, and C would have its own project-level
> Maven files as well as the master one that lives at the top level. Is
> this the right approach?

No, but close. You're correct that each subproject has its own
project.xml. Each declares the dependencies for that subproject.

If I remember correctly, one or more of the plugins don't like having
subprojects stored in subdirectories of the current directory. When I
set up our codebase to use multiproject, I set up the "master" project
at the same level in the directory tree instead of at the top:

  (top level dir)
    |
    +-- master
    |
    +-- A
    |
    +-- B
    |
    +-- C

The project.xml for A lists B as a dependency. The project.xml for C
lists A as a dependency. The project.xml in master is about as simple as
it can get without Maven complaining; most importantly, no dependencies
are declared in it.

Then you'll need to add to project.properties in master:

  maven.multiproject.basedir=..
  maven.multiproject.includes=A/project.xml,B/project.xml,C/project.xml

If you cd to master and run "maven -Dgoal=... multiproject:goal"
(replacing "..." with an appropriate goal), Maven should apply the goal
to the subprojects in the appropriate order.

Now, to be able to build a subset, create a directory at the same level
as master:

  (top level dir)
    |
    +-- master
    |
    +-- subset
    |
    +-- A
    |
    +-- B
    |
    +-- C

Copy project.xml and project.properties from master to subset. Edit
project.xml as necessary. Edit maven.multiproject.includes in
project.properties to list only the modules you want to include in this
subset. Build as above.

Hope this helps.

-- 
Craig S. Cottingham
craig@cottingham.net


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


Re: Basic Maven Question - Dependencies

Posted by David Jencks <da...@coredevelopers.net>.
geronimo does something like this from the top level build.  You can 
specify the list of modules you want to compile on the command line:

maven -Dmodules=A,B,C rebuild

geronimo actually has a 2 level approach that you can customize.

you can also easily define targets with predefined lists of modules.

david jencks

On Friday, February 13, 2004, at 11:58 AM, James Higginbotham wrote:

> I've done some preliminary searching and reading of articles, docs, 
> etc.
> regarding Maven and multiple-subprojects, but haven't been able to
> determine an answer to the following question:
>
>
>
> Assuming a project structure of:
>
>
>
> Project
>
>     |
>
>     |--A
>
>     |
>
>     |--B
>
>     |
>
>     |--C
>
>
>
> Where A depends upon B and C depends on A, the typical compile steps to
> build the entire project would be B->A->C. I've seen articles regarding
> the use of a reactor to provide a one-step method of making this 
> compile
> happen for all subprojects. However, our project has a large number of
> modules and we'd like to build a subset of them for quicker testing
> purposes by running Maven from, for example, subproject A (should build
> and deploy only B and A, not C). This would prevent me from having to
> compile all modules to simply test a set of 3 modules and deploy an EAR
> with those components. Is this possible using typical Maven constructs?
> What would be required to accomplish this using Maven? My first thought
> is that each subproject A,B, and C would have its own project-level
> Maven files as well as the master one that lives at the top level. Is
> this the right approach? Anyone doing this? Any best practices 
> suggested
> with larger projects?
>
>
>
> Best Regards,
>
> James
>
>
>


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