Automatically Build and Include One Eclipse Project Into Another

You can automatically build and consume one project into another as a Java jar file in your Eclipse or Rational IDE.

This will save you from having to right-click and export every time you change code in the project that’s consumed. Or it can save you from having to write a build script just for this purpose, which I am embarrassed to say I've done (more than once).

  • In your Eclipse or Rational IDE, right-click on the destination project and select Properties.
  • Select Java Build Path and then the Projects tab.
  • Click Add… to add the dependency project that you want to consume as a jar file.
  • Next, in the left-hand side of the Properties dialog, switch from the Java Build Path to the item that says Deployment Assembly.
  • Click Add… and select the project to be consumed as shown below

  • Finally, click Apply and OK.

Now, when I build my web app project, my base22-commons library (a separate project) is now automatically built and included in WEB-INF/lib as base22-commons.jar.