Maven - Generate Jar and War

Mohamed picture Mohamed · Jun 2, 2012 · Viewed 57.3k times · Source

I have a CXF WS project that I would use it in another project, I would consume this WS in a Web Project but I don't know how to generate Jar file.

Please have you any idea or an example?

Thank you

Answer

bmargulies picture bmargulies · Jun 2, 2012

The maven-war-plugin supports creating a separate artifact that just contains the classes.

http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html

See the 'attachClasses' parameter. No need to add in the jar plugin or mess with the packaging. Just add the war plugin to pluginManagement and turn this on.

However, I fear this this isn't what you want. To consume a CXF web service, you need a client. To get a client, follow the instructions in the CXF samples for how to generate and use client stubs. You'll want a separate maven project for this.