且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过示例Gradle Thrift插件

更新时间:2022-10-15 23:34:20

因此,您应该可以将以下内容添加到您的构建脚本中

  compileThrift {
outputDir = file('src / generated / thrift')
}

sourceSets {
main.java.srcDirs + ='src / generated / thrift / gen-java'
}

所以thrift插件将生成到src下的一个文件夹中(我只是喜欢这个,对于源代码正在构建中)

然后您可以将这些源代码添加到java插件检查的目录中。



不了解您的额外python问题


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?

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