我写了一个简单的 gradle 任务来生成 thrift 文件:
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(",") ]
}
}
这对我来说很好。我想要做的是将它连接到构建过程中,以便存根包含在我的 JAR 文件中。我很难找到一个很好的例子来说明在哪里挂钩,以及将文件写到哪里以便它们包含在我的 JAR 中。执行此操作或有示例的项目的最佳方法是什么?