循环遍历maven中的特定资源文件以生成源 [英] Loop through specific resource files in maven to generate sources
问题描述
我使用maven-antrun-plugin从thrift IDL生成源代码。
I use maven-antrun-plugin to generate sources from thrift IDL.
我有一个单独的项目(和jar)来保存这些生成的源,这个插件不支持通配符替换,所以我不能说* .thrift。
I have a separate project (and jar) to hold these generated sources and this plugin does not support wildcard replacement, so I cannot say *.thrift.
我使用执行任务来生成源并将它们复制到src目录。我已定义以下插件
I use execution tasks to generate the sources and copy them to src directory. I have the following plugin defined
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<mkdir dir="target/generated-sources" />
<exec executable="${thrift.executable}" failonerror="true">
<arg value="--gen" />
<arg value="java:beans" />
<arg value="-o" />
<arg value="target/generated-sources" />
<arg value="src/main/thrift/MyThriftResource.thrift" />
</exec>
<delete>
<fileset dir="src/main/java" includes="**/*" />
</delete>
<copy todir="src/main/java">
<fileset dir="target/generated-sources/gen-javabean" />
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
现在如果我想使用另一个thrift IDL,那么我需要再为该特定定义一个执行文件。我不想为每个添加的IDL做这个,我想说选择所有的thrift文件并生成源代码。有办法吗?
Now If I want to use another thrift IDL, then I need to define one more execution for that particular file. I do not want to be doing this for every IDL added, I want to say pick all thrift files and generate sources. Is there a way to do it?
推荐答案
也许你可以检查一下 maven-thrift-plugin 有帮助吗?
Perhaps you could check if maven-thrift-plugin helps?
这篇关于循环遍历maven中的特定资源文件以生成源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!