3.2.2. Configuring IntelliJ IDEA

For optimal use of MetaFactory with IntelliJ some configuration is required. Resolving XML errors

When opening a MetaFactory pattern.xml, the namespace and schemalocation will be marked in red, as shown in the screenshot below:


Update namespaces in text and images


Now move your cursor to the red marked namespace and press ALT-ENTER to resolve the issue. Choose the option “Manually setup external resources”.


Subsequently navigate to the MetaFactory installation folder and select the right XSD in the support sub folder.


..rubric:: Namespaces**












model.xsd Live Templates

In order to use the live templates with MetaFactory you need to copy the file Freemarker.xml from the support/idea folder of the installation path to the ‘Settings’ folder of IntelliJ.





Exclam M If the folder ‘templates’ does not exist, please create it.

The result will look as follows:

../_images/IntelliJLiveTemplates-730x768.png Implicit objects in Freemarker or Velocity templates

MetaFactory places a number of objects inside the context of Freemarker or Velocity. IntelliJ will need to know about these objects so that the error messages such as the ones shown below will disappear:


The first step to achieve this is to add 2 jars from the MetaFactory installation as a Global Library inside the project:


Add metafactory-api-<version>.jar, jdom2-<version>.jar and commons-lang3-<version>.jar as a Global Library.

Copy the files freemarker_implicit.ftl and velocity_implicit.vm from the support/idea sub folder of the MetaFactory installation to the snippets section of the MetaFactory project.

After copying these files to the sources root of IntelliJ they will be automatically detected and used. Whether the sources root is located at the module level or as a sub folder of that depends on the module. In some cases sources root doesn’t exist yet at all, then the directory will have to be explicitly marked as such:


Check M When all of this has been done, the error messages will disappear from the Freemarker en Velocity editor and auto complete can now be used on its objects.