views:

633

answers:

4

I have a java project that is composed of 3 sub projects that generate a .jar artifact each (and have sub-dependencies among them). In addition there is a web projects that depends on the first 3 projects and generate a war file. The war file is my final artifact, i.e. what I ship my customers.

Additionally I have a parent module that encompasses all the other projects:

<modules>
    <module>../core</module>
    <module>../commons</module>
    <module>../api</module>
    <module>../web</module>
</modules>

I generate eclipse files (mvn eclipse:eclipse) and work with eclipse. The problem is if I modify one of the non-web projects I must manually install it before deploying the web project to my web container. How can I make that the web project depends directly on the source code of the others and not on the version installed in the repository.

A: 

In your web application properties (right clic on the project in the Package explorer, then "properties"), add the three modules (core, commons and api) in the "J2EE Module Dependencies" (the others modules must be opened in the Eclipse workspace).

romaintaz
no, I want maven to be aware of the source dependencies. eclipse is ok.
flybywire
ok, now I get what you want to do. However, I don't think Maven will allow that...
romaintaz
A: 

Do you want to add a dependency on the source jars deployed to the repository?

If so you can do it by adding the sources classifier to the dependency. See this answer for more details.

If not, can you clarify further please.

Rich Seller
A: 

I think your problem is that you are just building just the war project. If you are building it from the command line, then what you have to build is the parent module. "mvn package" in the directory that contains the parent module should be enough. Of course this means that you have to build all the packages every time, but that is the way maven works.

dAni
A: 

The dependency:tree goal by itself will look things up in the repository rather than the reactor. You can work around this by mvn installing, as previously suggested, or doing something less onerous that invokes the reactor, such as

mvn compile dependency:tree

Works for me.

Edit: D'oh! Posted this answer to the wrong question. Was meant to be answering this

Don Willis