Adding a Web Project as a jar in an Eclipse Deployment Assembly

Alex Ciminian picture Alex Ciminian · Jan 11, 2011 · Viewed 7.6k times · Source

The site I'm working on now is made up of several java projects and a main web project A which references them. The IDE I'm using is Eclipse Helios.

What I'm trying to accomplish is adding a new project B to the stack. The project is also referenced by the main one, but is in itself a Web Project. When I add B to the Deployment Assembly of A, when publishing, Eclipse automatically packages it as a war and deploys it to the server's WEB-INF/lib.

I want it to be deployed as a jar, but also keep the project's web nature, as it has some features (and tests) that are run on it. I have ant tasks in place for building a jar out of B, but I don't know how to use them in Eclipse. Also, I'm not sure if it's possible to make Eclipse deploy a jar out of a web project.

I can add the jar manually (as an archive from the workspace), but that would mean that whenever someone cleans all projects, the jar for B would get deleted and not generated, as the build only compiles the classes and the deploy packages them into the war.

P.S. I know the design is poor, but changing it is out of the question as I don't have the authority :).

Answer

Serge Démoulin picture Serge Démoulin · May 19, 2015

I found the following solution that works for me on Eclipse Luna

  1. Project B "Project Facets" : select "Utility Module" instead of "Static Web Module" or "Dynamic Web Module"

  2. Project A "Deployment Assembly" : remove "B" and add it another time.

=> The "Deploy Path" of B is now B.jar