Contact Us 1-800-596-4880

Importing a Maven Project into Studio

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.

If you have a Mule project that was built using Maven outside Anypoint Studio, you can still import it into Studio and continue to work on it with the benefits of the Studio IDE.

Important: if you use the Maven studio:studio goal, you cannot use the m2ecplipse plugin, because it will override the studio:studio goal. Anypoint Studio has built in capabilities for importing and exporting between Maven and Studio using the studio:studio goal, which covers most use cases.

Assumptions

This document assumes that you have downloaded and installed Anypoint Studio. If you do not have any previous experience with Eclipse or an Eclipse-based IDE, please review the brief introduction to the Anypoint Studio interface. The document also assumes you’re familiar with Apache Maven.

Importing a Maven Project into Studio

Studio has a built-in functionality to import a Maven project.

  1. In Studio, go to File > Import…​

  2. Select Mule > Maven-based Mule Project from pom.xml, then click Next.

    import maven
  3. Navigate to the location of the pom.xml file you wish to import. Mule will automatically populate a Project Name, but you can adjust it.

    ImportMaven1
  4. Be sure to select the runtime you wish to use. Check Copy project into workspace if you want to create a copy of your project that resides in your workspace.

  5. Click Finish.

Anypoint Studio then internally runs the studio:studio goal and imports the Maven project into Studio, building the folder structure and files based on the instructions in the POM.

Troubleshooting

M2_REPO Classpath Variable Errors

After you open your Maven project in Studio you might encounter error messages (as illustrated below). You may need to set the M2_REPO classpath variable or, if it has already been set, re-point it to the correct repository.

error_message
  1. In Studio, right-click your project’s name in the Package Explorer, then select Properties.

  2. In the Properties pane, click Java Build Path in the menu on the left, then click the Libraries tab.

    build_path-1
  3. Click Add Variable…​.

  4. In the New Variable Classpath Entry panel, click the Configure Variables…​ button.

    new_variables_2
  5. Select the M2_REPO item from the list of classpath variables, then click Edit…​.

    If M2_REPO does not appear as an item in the list of classpath variables, click New…​ to create this classpath variable.
    M2_repo_2
  6. Change the contents of the Path field to specify the location of your Maven (.m2) repository.

    edit_variable_entry
  7. Click OK in each of the open panels to save your changes.

  8. Click the Problems tab in the console to confirm that the errors are no longer listed, which means they have been resolved.

Missing Required Repositories

You might also encounter the error below:

Failed to execute goal on project schema-extractor-plugin: Could not resolve dependencies for project org.mule.tooling:schema-extractor-plugin:maven-plugin:1.0-SNAPSHOT…​

Mule is indicating that some dependencies or artifacts cannot be resolved. Ensure that the required plugin repositories are included in your pom file.

<pluginRepositories>
        <pluginRepository>
            <id>mulesoft-release</id>
            <name>mulesoft release repository</name>
            <layout>default</layout>
            <url>http://repository.mulesoft.org/releases/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
  </pluginRepositories>

See Also