Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Subproject .class dependencies

 
Dave Boden
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following project layout
|
|- Project A
|
|- Project B
|
|- Project C

Project C has compile time dependencies on the generated class files of Projects A and B.

I've declared the dependencies in the Maven pom.xml files.

When I run the "compile" goal for Project C, it expects to find the .jar files for Project A and Project B in the repository. How do I configure it so that it looks for the .class files in Project A and Project B? Or have I got the wrong end of the stick, do I *need* to create the Project A and Project B jar files first?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
Yes, you need to build projects A and B first. Maven imposes a project structure on you, so you have to do it that way. This makes build files simpler if you can work that way.
 
Dave Boden
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

So, if I do an:
m2 compile

on Project C (with dependencies setup to A and B in the pom.xml) then it won't work. Which goal can I use to compile C and force a recursive build of A and B which will result in A and B's jar files being updated in the repository.

Surely this is a very common task? I shouldn't have to run 3 commands to acheive this, Maven 2 should be able to work it all out for me.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using maven 1.1 multi project build and i want to build all the sub projects (that have inter-dependencies) at one go. So i added a custom goal on each of the sub projects and the top level project and gave the same name. They in turn do what they need to (creates jars, war and ejb-jars)

Now if I call the newly created top level project goal using multiproject goal, it calls the corresponding goal defined in each of the sub-projects. But what I'm not sure about is the order in which its calling.

Say I have sub projects A,B,C
How does Maven know that that the sequence s'd be A-B-C and not C-A-B or something else? Its working now but I'm not too comfortable.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, it just occured to me after posting the question !-
Did Maven infer the subproject build order by reading the project.xml from each of the sub projects and evaluating the specified dependency (on a related subproject)?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic