通过示例Gradle Thrift插件 [英] Gradle Thrift Plugin by Example

查看:512
本文介绍了通过示例Gradle Thrift插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意:虽然此问题特别呼吁 Gradle Thrift插件,我相信这只是一个普通的Gradle问题,任何厌烦战斗的Gradle老兵都可以帮助我。




我是的新手,只熟悉Gradle(2.4。 X)。我试图让Gradle Thrift插件工作,并遇到一些问题,这些问题可能只是我Gradle知识中的空白。



这是我的示例项目:节俭



如果你克隆它并运行 ./ gradlew compileThrift ,你会发现它正是Gradle Thrift README所说的。它会在 build / generated-sources / thrift / * 下生成源代码。我想编译并构建这个资源。对于它生成的Java源代码,我想生成一个JAR库... 那么最好的方法是什么?我应该复制 build / generated-sources / thrift / gen-java / * src / main / java ,然后运行 build

解决方案

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

  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

这篇关于通过示例Gradle Thrift插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆