Search code examples
javaeclipsemavenjarm2eclipse

How to quickly replace a Maven Dependency with an Eclipse project?


I have setup a Dynamic Web Project in Eclipse using Maven. The Web Project has a lot of dependencies to other JARs. The JARs are properly added to the WEB-INF/lib folder in Maven/Eclipse. Many of the JARs though are results of other plain Java projects. I want to have the JARs represented by their resepective Java projects in Eclipse from time to time (but not for all of them).

So how do I quickly replace a normal Maven Dependency JAR by its Eclipse project?

Currently I:

  1. Remove the Maven Dependency (Right click on the JAR, Maven -> Exlude Maven Artifact)
  2. Edit the Build path and add the corresponding Eclipse project
  3. Mark the project also in the "Export and Order" section of the Build path
  4. Edit the Deployment Assembly properties and add the Eclipse project there as well (so it goes into WEB-INF/lib at runtime).

Solution

  • If your web projects is a maven project (little "m" in the upper left corner) and you have installed the M2E-WTP plugin (included in the Keplar JavaEE package), this will happen automatically, i.e. when the dependent project is open in the workspace, it will be a project link, if it is closed, your web project will use the jar file as dependency.