Gradle Thrift Plugin by Example
Question
I am new to Apache Thrift and only quasi-familiar with Gradle (2.4.x). I am trying to get the Gradle Thrift plugin to work and am encountering a few issues that are likely just gaps in my Gradle knowledge.
Here is my sample project: thrifty
If you clone it and run ./gradlew compileThrift, you'll see it does exactly what the Gradle Thrift README says it will do. It generates source under build/generated-sources/thrift/*
.
I would like to compile and build this source. For the Java source that it generates, I'd like to produce a JAR library...so what's the best way to do this? Should I copy, say, build/generated-sources/thrift/gen-java/*
to src/main/java
, and then run build?
Answer
so, you should just be able to add the following to your build script
compileThrift {
outputDir = file('src/generated/thrift')
}
sourceSets {
main.java.srcDirs += 'src/generated/thrift/gen-java'
}
so the thrift plugin will generate into a folder under src (I just prefer this, to source code being in build) and then you can add these sources to the directories the java plugin checks.
Link
http://stackoverflow.com/questions/35232344/gradle-thrift-plugin-by-example