• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Subproject .class dependencies

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)?
 
We can walk to school together. And we can both read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic