Currently, my built structure for a plugin in is a bit messy: I'm using the normal IDEA project file to build the plugin locally. When I push it to the repo and travis-ci is building it, it uses the maven pom.xml because for travis to work, it always has to download the complete IDEA sources.
Although this works, this has several drawbacks:
- I need to keep two built mechanisms up to date. This is
- When a new IDEA version is out (every few weeks), I need to change the SDK in maven and in my IDEA settings
- When I add a new library, change resources, etc. I need to do this for two the two settings as well
- I ran into problems when I kept the IDEA Maven plugin turned on because it saw the
pom.xmland interfered with my local built. Turning it off means, I cannot download libraries with Maven which has the feature of tracking dependencies.
I saw that Gradle has an 'idea' plugin and after googling, I got the impression that Gradle is the preferred choice these days. I have seen Best way to add Gradle support to IntelliJ IDEA and I'm sure I can use the answers there to turn my pom.xml into a valid build.gradle.
However, maybe someone else has already done this or can provide a better approach. What I'm looking for is a unified way to build my plugin locally and on Travis-CI.
Some Details
For compiling an IDEA plugin, you need its SDK which you can access through an installation of IDEA or a download of the complete package. Locally, I'm using my installation for the SDK. With Travis, my maven built has the rule to download the tar.gz and extract it.
It turns out that in particular for building an IntelliJ plugin, Gradle seems to have many advantages. This is mainly due to the great IntelliJ plugin for Gradle which makes compiling plugins so much easier. With Gradle, I could turn my >220 lines of Maven build into a few lines of easily readable Gradle code. The main advantages are that
plugin.xml, e.g. you can use one central version number ingradle.buildand it will keepplugin.xmlup-to-date or it can include change-notesHow to use Gradle with an existing IDEA plugin
Do it manually. It's much easier.
build.gradlefilebuild.gradleof projects at the end) to see what each intellij property does.intellij.versionyou want to build againstintellij.pluginNamegradle wrapper./gradlew assembleIf everything works well, you can push
build.gradle,gradlew,gradlew.batand thegradle-folder to your repo.Building with Travis-CI
For Travis you want to use the
gradlewscript for building. To do so, you need to make it executable in the travis run. An example can be found here.