Gradle Thrift Plugin by Example

不想你离开。 提交于 2019-12-14 02:00:23

问题


Please note: Although this question specifically calls out the Gradle Thrift plugin, I believe this is just a general Gradle question that any battle-weary Gradle veteran could help me with.


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?


回答1:


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

no idea about your extra python question



来源:https://stackoverflow.com/questions/35232344/gradle-thrift-plugin-by-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!