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 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.
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.