Apache Thrift, IntelliJ Idea, Gradle — How To

While most tools available on the Internet have good documentation, I stumbled upon this quagmire and hope someone will benefit from my experience.

I’m a complete noob in IntelliJ Idea and Gradle. For many years I was an Eclipse and straight Ant guy, with a little Maven when it was convenient. However, when I joined Upwork I found most people using Idea and swearing on everything they hold dear that it’s a way more user friendly and productive environment. I also heard Gradle to be superior to (and newer than) Maven so I decided to try these tools for my next coding project. As a part of the project I needed to build Thrift-based message definitions. My initial requirements seemed simple:

  1. Complete UI support of Thrift, including syntax highlighting, error checking and other visual candy.
  2. Seamless 1-click (or hotkey) triggered build of the project
  3. Ideally no separate install of Thrift’s compiler. Why have an IDE if you have to deal with classpath and path outside of it?

Right off I discovered what there is no embedded support for Thrift in Idea. I expected that, as plugin-based design is an obvious more scalable choice. In fact, plugin-based design is used by the majority of modern tools, including Eclipse, Atom etc. What I didn’t expect is that the most popular (and pretty much only) plugin for Thrift in Idea has literally no documentation whatsoever. As you can see for yourself here: https://plugins.jetbrains.com/plugin/7331-thrift-support More to the point, there is no list of capabilities for the plugin! I had no idea if it compiles the definitions by itself or it needs something else, could it also work as Gradle plugin, how to make it understand what files it needs to look into for thrift definitions etc. Like I said, I am a complete noob in Idea so reading the plugin’s source code didn’t help me any. Luckily, there is a discussion board for the plugin at https://github.com/fkorotkov/intellij-thrift/issues . Through the rather disconnected forum topics, I was able to figure out that I need a separate Thrift compiler and the plugin is looking for files with extensions .thrift. It also became clear that the plugin doesn’t work with Gradle. In a moment of weakness I tried to remove Gradle and just go with a plain Idea project but I couldn’t make everything build. Idea kept on complaining about “NoClassDefFoundError: org/apache/commons/io/FileUtils”. As I couldn’t figure out why that file is needed and where it’s missing from, I decided to go back to Gradle. I’ve got to give it to Idea people: they made it real easy to add and remove different types of build to project. With Gradle plugins I had way more luck — there is one Thrift Gradle plugin ( https://github.com/jruyi/thrift-gradle-plugin ) and it has documentation! Unfortunately, the documentation doesn’t specify that you need to explicitly add Thrift’s library to Gradle otherwise your Thrift-generated sources won’t compile. I still needed an external installation of Thrift compiler but at least now everything worked. To summarize, here are the steps one needs to go through to make Thrift work with Idea/Gradle (btw, I couldn’t make it work without Gradle):

  1. Install Idea’s Thrift plugin
  2. Install Thrift’s compiler ( https://thrift.apache.org/download) somewhere on your machine separately

3. Configure Thrift compiler’s path in Idea (Settings -> Compiler -> Thrift Compiler)

4. Add Thrift compiler plugin to Gradle, like it’s described in the documentation

5. Add Thrift’s library to Gradle like so:

dependencies {



At last but not least, it works best if you build (Control-Shift-F9) the whole project (the topmost line in the project view).

I hope this post helps someone find their way in this confusing buildspace, good luck!



Architect at Upwork

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store