I wrote a simple gradle task to generate thrift files:
task generateThrift << {
thriftFiles = fileTree(dir: 'src/main/thrift').matching { include '**/*.thrift' }
exec {
executable = 'thrift'
args = ['--gen', 'java:hashcode', '-o', '/tmp', thriftFiles.collect { relativePath(it) }.join(",") ]
}
}
This works fine for me. What I want to do is hook it into t开发者_如何学运维he build process so the stubs are including in my JAR file. I'm having trouble finding a good example of where to hook this in, and where to write the files out to so that they are included in my JAR. What's the best way to do this or a project that has an example?
I suggest to write the files to a subdirectory of the build output directory, say thrift-stubs
. Then you can include them in the Jar like so:
jar {
from "$buildDir/thrift-stubs"
}
精彩评论