Building an IntelliJ plugin using Gradle is easier than you might think

I recently had the problem of automating the build of an IntelliJ plugin so more of the process of updating the plugin could be automated.

I found a lengthy write up by Arjan Molenaar (opens new window) which I followed to originally get ServiceStackIDEA building on a new CI server. This use the idea gradle plugin to handle some of the IntelliJ project specifics. Although it works, it's quite verbose and requires the need to resolve the IDEA SDK zip, extract them temporarily, strip out dependencies so your plugin isn't huge amongst other things.

Even though I researched trying to solve this problem quite extensively and found quite a few artciles on how to do this, I missed the fact that Jetbrains have packaged all this required logic to get your IDEA plugin building for you in an easy to use gradle plugin of their own.

So the original 120 lines of quite fragile gradle gets turned into this.

plugins {
  id "org.jetbrains.intellij" version "0.0.23"

apply plugin: 'org.jetbrains.intellij'

intellij {
  version '14.1.4'
  plugins 'coverage'
  pluginName 'MyPlugin'

  publish {
    username 'zolotov'
    password 'password'
    pluginId '5047'
    channel 'nightly'

So if you're trying to build an IntelliJ/IDEA plugin on a CI server, or even starting a new one, start with the gradle-intellij-plugin (opens new window).