Configuring Geany for Maven Projects

Maven is a great lightweight IDE for small Java projects based on Maven. Once you make a few configurations it will help you do 80% of what a big IDE can do, but with only 20% of the cost.

To get the most out of Geany, you want to:

  • Enable call tips and auto-completion.
  • Call Maven and capture error messages.

Call tips and auto-completion

First you want to have autocompletion and call tips for most classes on the JDK. You do this by downloading and installing a suitable tags file. You can find them in the Tag Files page.

Additionally, to create tags for project's files you can use the GProject plugin. Once enabled you will get a new tab labeled GProject in Geany's Project configuration window. Set the project file extension here (*.java) and tick the tag generation box. With this you gain auto-completion for your project's own code, even when not open.

Calling Maven

Finally you want to be able to call Maven from Geany, and then capture error messages, so you can quickly go to the offending lines. You do this by configuring the project's build commands.

Go to Geany's Project configuration Window (Project > Properties), and then to the Build tab. Here you can set the Independent Commands section with the following values:

1. _Compile mvn compile %p
2. _Other targets mvn %p
3. _Test mvn test %p
4. _Package mvn package %p
Error Regular Expression \[ERROR\] ([^:\[]+):?\[([0-9]+)

With this setup you can invoke a Maven and compile your project with Shift+F9, and run your unit tests with Shift+F8. With the shortcut Ctrl+Shift+F9 a pop-up window will allow you to specify other targets, such as clean or deploy. Any error will appear in red in the Compiler window, and double-clicking on that line will bring the editor to the reported position.

Note that it is assumed that your POM file is located in the project's root directory. If it is not the case, modify the working directory column to suit. You can get more help on customizing the build options in Geany from the page User Guide to configuring the Build Menu.