Adding a jar web project to the Eclipse deployment assembly

The site I'm working on now consists of several java projects and the main web project A , which links to them. The IDE I use is Eclipse Helios.

What I'm trying to accomplish is to add a new project B to the stack. The project also refers to the main one, but in itself is a web project. When I add B to deployment assembly A , when published, Eclipse automatically packs it like a war and deploys it to the WEB-INF/lib server.

I want it to be deployed as a jar, but also preserve the nature of the project website, since it has some functions (and tests) that are performed on it. I have ant tasks for creating a jar from B , but I don't know how to use them in Eclipse. Also, I'm not sure if you can get Eclipse to deploy the jar from a web project.

I can add the jar manually (as an archive from the workspace), but this will mean that whenever someone clears all projects, the jar for B will be deleted and not generated, since the assembly only compiles the classes and deployment packs them into war .

PS I know that the design is bad, but changing it is out of the question, because I have no authority :).

+2
java eclipse jar deployment
source share
3 answers

The easiest way: File -> Export ... -> Java -> Jar File

To use ant: open project properties, go to the collectors, click "Create", "Select" Ant Builder, etc.

+1
source share

You can do something like this:

  • Write a shell / package script that
    • calls the ANT script of project B, which creates the JAR file.
    • and then it calls project ANT script A.
  • Update the ANT script of project A, add the copy task. This file copy task will use the relative path to copy the JAR file created in step 1 to create the A WEB-INF / lib directory.
  • In Eclipse, go to External Tool > External Tools Configuration > Program > New Progam and add this shell / package script to it.

Whenever you want to build. Launch this external tool from the menu. This will provide

  • Your build always has the latest version of Project B
  • ANT tasks will remain small.

Adding a web project to an Eclipse deployment assembly

I did not know anything like this until Thorbjørn Ravn Andersen pointed to another question that I answered . As mentioned there:

What happens in the deployment is not determined by the assembly path, but by the Assembly Assembly entry in the settings for a dynamic web project.

But perhaps you have already tried this.


Edit # 1: fixed grammar Edit # 2: added more information

+1
source share

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

  • Project B “Project Boundaries”: select “Utility Module” instead of “Static Web Module” or “Dynamic Web Module”

  • Project A Deployment Build: Delete B and add it at a different time.

=> "Deploy path" B now B.jar

+1
source share

All Articles