3.5. Importing an existing project

Follow this quick start guide to change an existing Java project such that you can use Metaborg languages in it.

  1. Open the project in IntelliJ IDEA.

  2. Go to the Project Structure dialog, either through the FileProject Structure… menu item, or by pressing Ctrl+ Alt+Shift+S.

  3. Go to the Facets tab.

  4. Click the ../../../../../_images/button_plus.pngPlus button and select Metaborg from the drop-down menu.

    ../../../../../_images/projectstructure_addmetaborgfacet.png"Project Structure" dialog

  5. Select the module to add the facet to, and click OK.

  6. In the Modules tab, select the module.

  7. Go to the Dependencies tab.

  8. Select the Metaborg SDK as the module’s SDK.

    ../../../../../_images/projectstructure_setmetaborgsdk.pngSelect the "Metaborg SDK"

    Note

    If the Module SDK displays <None> and you can’t select the Metaborg SDK, then you need to add it first.

    1. Click the New… button next to the Module SDK field.

    2. Select Metaborg SDK.

      ../../../../../_images/projectstructure_newsdkmenu.png
    3. You may get a warning if you have no Java JDK configured. Click OK and configure the JDK’s home location. The suggested home directory is usually correct. Click OK.

    4. Select a home directory for the Metaborg SDK. The default is the Spoofax plugin’s lib/ folder, which is sufficient as it contains all the core dependencies.

    5. Click OK.

  9. Click OK to apply the changes.

The Java project will have the Metaborg facet, indicating that the project uses Metaborg languages. It will also have a metaborg.yaml file, which specifies the language dependencies of the project.