I have two maven projects A and B, where B depends on A. (In my setup, the Serverproject needs the Commonproject to be build). Is there a way that I can tell maven to rebuild the subproject A everytime that I build B? What I'm doing right now is to build A and install it into my local repository. Afterwards I build B (in whose pom.xml i have declared the dependency for A). is there a way to build B without the need of prior installing A in my repository?
Welcome to the JavaRanch! We don't have many rules around the ranch, but we do have a policy on displayed names... Please adjust your displayed name to meet the JavaRanch Naming Policy. User names cannot be obviously fake and must consist of a first name and a last name.
I changed my profile (even though the link you posted was broken) and I'm just about to read the regarded text.
Thank you :-) I'll post when I solved my prob.
Joined: Nov 08, 2006
I read the regarded doc. Seems like I don't have what is called a multimodule project, but several "singlemodule" projects with "interproject" dependencies. I have a "Common" Project with a pom.xml, a "Server" Project with a pom.xml and a "Client" Project with a pox.xml. Every project is an Eclipse Project in the Workspace. The Server- and the Clientproject are both dependent on the Common Project. As far as I understand, what is described as Aggregation in the document is only possible for multimodule projects. And even the chapter Inheritance did not need my needs as the Common Project is not getting built while building e.g. the "Server" Project. So I'm quite lost :-( Any hints would be helpful.
Thanks for changing your name, and also for telling me that the "change my name" link is broken... I guess this changed in the last message board update.
If you're doing this with several single module projects, there's no way I know of to force one project to build when another one does (other than just manually doing so).
You could refactor your server and cleint projects to be sub-modules of your common project - this would probably be the best way to get one project to build another. You mentioned you are using eclipse, which unfortunately doesn't handle multi module projects too well. At least *creating* multimodule projects - from what I recall it's mostly ok if you create the projects outside of eclipse and then import them.
Joined: Nov 08, 2006
I managed to create a multimodule Project. Server and Client are submodules of the Common Module. I can call "compile" on the project and everything gets compiled in the right order. (Just how it is shown in the doc) But still I see a problem. If my Client Module needs classes from the common module I can ,in Eclipse, add the Common module (which Eclipse sees as a project) to solve dependency problems. How do I tell maven that I need classes from the Common module in the jar that I create from the Client module? If I would add a dependency in the clients POM then I would have to create a Common artifact which I had to store in a repository from which the client module would grab it. I rather look for a way to create that Common.jar (or just the compiled classes) "on the fly" without storing it anywhere (not in a repository). Maybe I'm still thinking in a "too ant(y)" way :-)
I think one of the major problems here is you're fighting one of Maven's core concepts.
Maven is intended to support large projects with lots of external components. Other similar build systems have suffered because someone in South Africa is using a module created by someone in Sweden who's just update it and the new version has fatal flaws in it.
To avoid this, Maven expects a finite set of formal product releases rather than just tapping into points in the supplier's build cycle. Essentially, the supplier comes to a stable point, marks it as a release with a specific version ID and publishes it in a place where consumers can then access it.
On the consumer side, their pom.xml declares a dependency on a specific release of a specific product. This means that once a given release of a product has been proven trustworthy for the consumer, that's the release that will be included in the consumer's build, until the consumer selects another (usually newer) release and verifies that it's safe. Less surprises that way, and very important on projects that may be pulling in a dozen or more dependencies, each on its own development schedule.
Of course this means that you have to modify the pom.xml as you release new versions of your library, which is inconvenient. However, if the library is that critical - and especially if multiple developers are using it, it's probably going to be better to take advantage of the fixed-release concept anyway.
An IDE is no substitute for an Intelligent Developer.
Tiago Rinck Caveden
Joined: May 16, 2008
Hello! Thank you for the response.
It's not that I am trying to fight anything. It's just that this is not what I am doing. I am not using a module developed at another corner of the world by dozens of people, I am developing both modules myself, in parallel. So, you see, creating stable versions all the time I want to test something I just wrote would be a really unnecessary extra work... And I wouldn't like to put everything under the same project because I don't think it makes sense (it's a "core" application and an "adapter" that will make this application work with another platform - the core app doesn't need to depend on this platform, but the adapter does and it also depends on the core app that I'm developing).
Anyway, it doesn't seem to me something so rare neither "ugly".. it's just compiling another project and getting it as a dependence... in Ant it would be a simple thing to do... that's why I thought maven would provide a way of doing so... isn't the case? There is no way?