Reputation: 11508
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 :).
Upvotes: 2
Views: 8066
Reputation: 55866
You can do something like this:
External Tool > External Tools Configuration > Program > New Progam
and add this Shell/Batch script to it.Whenever you want to build. Run this external tool from menu.This will ensure
Adding a Web Project in an Eclipse Deployment Assembly
I did not know any such thing, until Thorbjørn Ravn Andersen pointed this out in another question where I answered. As mentioned there:
What goes in the deployment is determined not by the build path but by the Deployment Assembly entry in Preferences for the dynamic web project.
But maybe you have already tried this.
Upvotes: 1
Reputation: 21
I found the following solution that works for me on Eclipse Luna
Project B "Project Facets" : select "Utility Module" instead of "Static Web Module" or "Dynamic Web Module"
Project A "Deployment Assembly" : remove "B" and add it another time.
=> The "Deploy Path" of B is now B.jar
Upvotes: 2
Reputation: 2641
The easiest way is: File -> Export... -> Java -> Jar File
To use ant: open project properties, the go to Builders, Click new, selec Ant Builder, etc.
Upvotes: 1