Working with IntelliJ IDEA

Last modified by Pierre Jeanjean on 2023/10/31 13:55

Install IntelliJ IDEA

Get the source for XWiki

The source for XWiki is available via a source repository.

Create an IntelliJ IDEA project

IntelliJ IDEA supports Maven out of the box so all you need to do is open the pom.xml file for the project you wish to build/debug.

Building sources

In IDEA's menu, click on Build > Make Project.

Enabling syntax highlighting for Velocity templates

The XWiki project relies extensively on Velocity templates.
It is possible to get support for syntax highlighting directly in the IDE by installing the following textmate bundle: https://github.com/textmate/java-velocity.tmbundle.
This can be done by going to File > Settings > Editor > TextMate Bundles and adding a local copy of the repository.

By default, simply installing this bundle will provide support for any .vm file. However, most Velocity templates in XWiki are embedded in documents, stored as .xml files.
The solution here is to use an extension that enables textmate language injection, such as https://plugins.jetbrains.com/plugin/22641-injectsense.
Once installed, you might want to edit the default shortcuts in File > Settings > Keymap > Plugins > InjectSense.
After that, when browsing an .xml file that contains Velocity syntax, you can put your cursor between, e.g., the <content>..</content> tags, press your shortcut, and select Java Velocity from the context menu.

Troubleshooting

Plenty of errors in imports

This mean IDEA wasn't able to resolve the dependencies of the module you're in. One typical cause is because IDEA failed to read the XWiki Maven POMs. And one reason for that is that XWiki requires a recent version of Maven, while IDEA may embed an oldish version. This is causing problems such as the one in the following screenshot, preventing IDEA from resolving dependencies:

maven-idea-bug.png

You also need to make sure that you've configured Maven properly with a good settings.xml file.

Get Connected