You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Trevor Harmon <tr...@vocaro.com> on 2008/08/26 01:15:09 UTC
Transitive dependencies in multi-module projects
Hi,
My application is divided into several transitively dependent
projects. Here's a simplified example:
libA.jar
libB.jar depends on libA.jar
libC.jar depends on libB.jar
appA.jar depends on libC.jar
appB.jar depends on libC.jar
Each of these JARs is in its own POM, which specifies the dependencies
stated above. I'm actively developing all of these projects
simultaneously, so I want Maven to compile the source code of any
dependency that's out-of-date (just like Ant's <javac> task). For
example, if I'm testing appA, and I change something in libB, I should
only have to run "mvn compile" on the appA project, since Maven knows
that appA depends transitively on libB. Unfortunately, this doesn't
happen. I have to manually figure out which dependent project is out
of date, compile it, and then compile appA. Needless to say, this is
tedious and time-consuming.
I've been reading that modules are the solution to this problem.
There's a write-up about them here:
http://docs.codehaus.org/display/MAVENUSER/Multi-modules+projects
However, the solution in the write-up doesn't seem like it would work,
at least not in my situation. It says I have to specify libC's parent
module, but which parent do I choose? As you can see above, it has two
parents: appA and appB. How can I reconcile this? Thanks,
Trevor
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Transitive dependencies in multi-module projects
Posted by Wendy Smoak <ws...@gmail.com>.
On Tue, Aug 26, 2008 at 6:37 AM, Trevor Harmon <tr...@vocaro.com> wrote:
> As I said, I want to be able to go to appA's directory and type:
>
> mvn compile
>
> Since Maven knows appA's dependencies, it should be able to figure out that
> if a source file in libB is out-of-date, it should compile libB first.
> Likewise, if I compile libB but libA is out-of-date, Maven should know to
> compile libA before proceeding.
>
> I'm guessing this just isn't possible in Maven?
Not really. The modules are intended to stand alone, so just because
you have a snapshot dependency on libA doesn't mean Maven knows where
the source code is. Building "from the top" from the parent pom level
and letting Maven figure it out is as close as I can get.
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Transitive dependencies in multi-module projects
Posted by Trevor Harmon <tr...@vocaro.com>.
On Aug 25, 2008, at 7:25 PM, Wendy Smoak wrote:
> If you establish a parent pom, and list all five of your projects as
> <modules>, Maven will figure out what order to build them in, and
> compile the changed sources.
Thanks for your suggestion, but unfortunately it does not accomplish
my goal. Adding a parent POM with the list of modules will do the
right thing *only* if I'm compiling the parent POM. If I'm compiling
any other module, Maven simply ignores the dependencies.
As I said, I want to be able to go to appA's directory and type:
mvn compile
Since Maven knows appA's dependencies, it should be able to figure out
that if a source file in libB is out-of-date, it should compile libB
first. Likewise, if I compile libB but libA is out-of-date, Maven
should know to compile libA before proceeding.
I'm guessing this just isn't possible in Maven?
Trevor
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Transitive dependencies in multi-module projects
Posted by Wendy Smoak <ws...@gmail.com>.
On Mon, Aug 25, 2008 at 4:15 PM, Trevor Harmon <tr...@vocaro.com> wrote:
> I've been reading that modules are the solution to this problem. There's a
> write-up about them here:
> http://docs.codehaus.org/display/MAVENUSER/Multi-modules+projects
> However, the solution in the write-up doesn't seem like it would work, at
> least not in my situation. It says I have to specify libC's parent module,
> but which parent do I choose? As you can see above, it has two parents: appA
> and appB. How can I reconcile this? Thanks,
In your example, appA and appB are not parents of libC... they simply
have a dependency on it.
If you establish a parent pom, and list all five of your projects as
<modules>, Maven will figure out what order to build them in, and
compile the changed sources. (It might not be quite as efficient as
Ant, for example I think if you run 'mvn install' it will still
package up and install the jar, even if nothing needed to be compiled.
YMMV.)
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org