在maven中需要时创建目录
我正在使用 maven-exec-plugin 生成 Thrift 的 java 源。它调用外部 Thrift 编译器并使用 -o 指定输出目录“target/ generated-sources/thrift”。
问题是maven-exec-plugin和Thrift编译器都不会自动创建输出目录,我必须手动创建它。 有没有一种体面/便携的方式在需要时使用创建丢失的目录?我不想在 pom.xml 中定义 mkdir 命令,因为我的项目需要独立于系统。
I am using maven-exec-plugin to generate java sources of Thrift. It invokes the external Thrift compiler and using -o to specify the output directory, "target/generated-sources/thrift".
The problem is neither maven-exec-plugin nor Thrift compiler automatically create the output directory, I have to manually create it.
Is there a decent/portable way use create missing directories when needed? I don't want to define a mkdir command in the pom.xml, since my project need to be system independent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
antrun
代替 exec 插件插件首先创建目录,然后调用 thrift 编译器。您可能还想查看 maven-thrift-plugin。
Instead of the exec plugin, use the
antrun
plugin to first create the directory and then invoke the thrift compiler.You may also want to take a look at the maven-thrift-plugin.
您可以定义一个 Ant 任务来完成这项工作。将
plugin
声明放入项目的 pom.xml 中。这将使您的项目系统独立:You can define an ant task to do the job. Put the
plugin
declaration into your project's pom.xml. This will keep your project system-independent:如果您想在项目中的某个位置准备此类文件夹结构,然后复制到您想要的位置,请使用 maven-resource 插件来执行此操作:
If you would like to prepare such folder structure somewhere in your project and then copy to place you want, use maven-resource plugin to do that: