How to automate your IntelliJ IDEA setup with Gradle

Our SaaS application is built with Java, managed with Gradle and runs on Google App Engine. That makes a surprisingly lean and agile combination. Since we do like to work with the best tools available the folks responsible for the back-end love IntelliJ IDE. So of course we utilize the IntelliJ plugin for Gradle. It’s amazingly simple to configure:

  apply plugin: 'idea'

That’s it. When we run

  gradle idea

it generates all IntelliJ files for us:

  • small-improvements.ipr (project configuration),
  • small-improvements.iml (module configuration)
  • and small-improvements.iws (workspace configuration).

We now have an IntelliJ project synchronised to our Gradle configuration. Great.

The Problem

Let’s get coding: You open IntelliJ. Eager to kill the most recent bug (it does happen). But wait! Before you can start the app you need to create an artifact from the generated module. After that you need to create a run configuration for ‘Google AppEngine Dev Server’. You then start the app only to realise that you forgot to add the correct JVM flags that enable debug functionality. So you copy the correct flags from the Gradle file.

Now you can get started. You fix the bug and restart the server. But the bug is still there! How can this be? After questioning your own sanity you notice that you forgot to check the option “Build on make”. This is just the tip of the iceberg, don’t get me started on what happens when the version of a dependency is changed …

Continue reading