Search code examples
javaintellij-ideathrift

Can't add Thrift support on a Java project


So I am trying to build a client server application, using Java for my Client and C# for my server. I made a Gradle project for my Java client, and I can't add Thrift to it no matter what I try.

This is how my gradle looks.

plugins {
    id "org.jruyi.thrift" version "0.4.0"
}

group 'com.artyomska.thrift'
version '1.0-SNAPSHOT'

apply plugin: 'java'

sourceCompatibility = 1.8


repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

Even after I built and assembled this Gradle, the following imports won't be recognized:

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

I have tried to use buildscript on the build.gradle file instead of plugins, I have tried to Synchronize the Gradle file with the project, I have tried Install Thrift Support 0.9.6 from Settings-Plugins, I have also added the Thrift as a framework to my project and I also tried to Invalidate the caches and restart, and still nothing works. I made 3 new projects since I thought maybe my folders or the Gradle for that project is corrupt, but nothing was resolved.

How can I make my Gradle project support Thrift, and those imports to work in it? I am using W10 with IntelliJ Idea Ultimate 2017.1 (last version)


Solution

  • Looks like you forget to add compile dependency to your project

    dependencies {
      compile group: 'org.apache.thrift', name: 'libthrift', version: '0.9.3'
    }