Synchronizing Dependencies Between Eclipse and Maven
When you work with software projects in Eclipse, you often need to refer to third-party libraries in your project. Since your source code is using the APIs and utilities exposed by these libraries, you must add them to the Eclipse project classpath (project buildpath) as dependencies to prevent compilation errors in the Eclipse IDE. If you are using Maven as your build tool, you must add these libraries as Maven dependencies in your Maven pom.xml
file. Likewise, if you want to use a Maven project in Eclipse, you need to synchronize the Maven dependencies with the Eclipse project. Developer Studio provides a simple way to synchronize the dependencies, as described in the following sections.
Update the POM file with dependencies from the Eclipse projectÂ
You can update your project's Maven pom.xml
file with the current set of third-party libraries in your Eclipse project buildpath. If you add another third-party library to your Eclipse project buildpath, right-click the project and click Maven > Sync Project Dependencies with pom.xml. The POM file will now contain the dependency you added to your Eclipse project.
Update an Eclipse project with dependencies from a POM fileÂ
If you want to open a Maven project in Eclipse and continue development, or if your existing Eclipse project maintains its dependencies in a pom.xml
file, you can run the command mvn eclipse:eclipse
 in the Maven eclipse goal against your project to generate your project descriptors or update existing project descriptors. This feature requires that you create a WSO2 Maven project using Developer Studio 3.0.0 or later. You must also use Eclipse M2Eclipse 1.2 or later and Apache Maven 3.0.* or later.
For example, let's assume you have a WSO2 Maven project called CustomMediator where you have only source files and a Maven pom.xml
file.Â
- In a command prompt/shell, go to the file system location of your Maven project, and then enter theÂ
mvn eclipse:eclipse
 command as described in the Maven eclipse goal. The Maven project is built as shown below: - In Developer Studio, if the current perspective is not Java EE, click Window > Open Perspective > Other > Java EE.
- Click File > Import.
- In the wizard that appears, expand WSO2, click Existing WSO2 Projects into workspace, and click Next.
- Click Browse and specify the Maven project location in the file system. When you specify the location, Eclipse automatically scans the file system, locates all the projects, and displays them under the Projects area.
- Select the project and click Finish.
You can now open your project and continue development in Eclipse.