如何使用thrift生成器作为maven依赖(如何避免引用.exe文件)?
我在pom.xml
有以下内容:
... ... org.apache.thrift libthrift 0.11.0 org.apache.thrift.tools maven-thrift-plugin 0.1.11 D:/work/thrift-folder/thrift-0.11.0.exe ../thrift-files java thrift-sources generate-sources compile
它很好但我不喜欢在我的源代码中引用.exe
文件:
D:/work/thrift-folder/thrift-0.11.0.exe
是否可以使用maven依赖? 怎么样?
所以,我认为你的问题的答案是,“不,没有办法避免将可执行文件的路径传递给插件。”
我能建议的最接近的是这样的:
在你的pom.xml中:
org.apache.thrift.tools maven-thrift-plugin 0.1.11 ${myProps.thriftExec} ../thrift-files java thrift-sources generate-sources compile
然后,在构建用户的~/.m2/settings.xml
:
thrift-build D:/work/thrift-folder/thrift-0.11.0.exe
现在,您可以检入您的pom.xml,它没有任何特定于机器的路径。 为了执行构建,需要定义属性myProps.thriftExec
,因此每个开发人员/构建者都需要在他们的机器上安装thrift并为自己定义该属性。 这样一来,Mac或Linux主机就不会试图找到Windows卷等等。
有关配置文件的详细信息及其便利的原因,请参阅Maven文档 。