Can I produce both jar and war from a project in maven?


I have a project(A) in maven that has packaging of war. One other project(B) depends on A and it needs project A jar file but in phase of compile, the war of project A will produce and no jar is available for project B. How can I create a jar of project A in phase of compile so that project B can use it?

I would suggest to go a different way and use the maven-war-plugin which can produce a separate artifact for the classes which can be used like the following:


This can be achieved by using the following configuration in your war module: