maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anders Hammar <>
Subject Re: How to collect module dependencies in a Java Mojo in a parent project?
Date Fri, 11 Feb 2011 14:42:58 GMT
I'd like to first stress the fact that an aggregating project and a parent
project is two different things. A pom project might be used for both
things, but it's not necessarily true.
So, your pom project which holds the list of modules is an aggregating
project. It's primary use is to aggregate the build of all the modules. The
modules do not know of this project, and does not inherit anything from it.
A parent project is the project you declare as the parent in a Maven
project. Things like dependencies and bound plugins are inherited. However,
the parent project does not know of its children. It's like in Java - a
class doesn't know of the classes which extends it.

After this lesson, back to your question. I would need to know what
resources you're trying to generate and what for, to say for sure if it's
the right way to do it. If you're creating some aggregating report then I
believe it's ok (have a look at the javadoc:aggregate).

The reason your goal is being executed on all modules is because that's how
Maven works when you execute something on an aggregating project. You can
use the "-N" switch to stop Maven from execute recursively.


On Fri, Feb 11, 2011 at 15:22, tgrzej <> wrote:

> Hi,
> I'am new to Maven and I have a task to do which I don't really know if it
> fits "The Maven style" of doing things and therefore I look for some
> advice.
> My requirements are as follows:
> * I have a project that contains several subprojects/modules. The project
> has its pom that lists modules so that all modules can be built together
> (the packaging of the main project is "pom", at least for now).
> * Each module has its own dependencies and can possibly be built
> independently of other modules. Each module has its own pom which points to
> a parent project (submodules have custom packaging but I don't think it's
> relevant).
> * I want to write a plugin (Java Mojo) that could be run on the main
> project
> and that would have access to all dependencies of all its modules (I need
> to
> generate some resources for the parent project based on the list of all
> dependencies of all modules). The goal that I'am going to write should/can
> be a standalone goal (not a part of any building phase).
> When I run my custom goal on the main project it than gets executed on
> every
> module. I can use this iterating behaviour to collect all of the
> dependencies from modules, but somehow it looks like a hack. What I really
> want to achieve is to just run my goal once for the main project and being
> able to access all the modules and their dependencies from there. So my
> question is how can this be achieved in the most simple and elegant way?
> Regards,
> Tomasz
> --
> View this message in context:
> Sent from the Maven - Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message