我使用 maven-antrun-plugin 从 thrift IDL 生成源代码。
我有一个单独的项目(和jar)来保存这些生成的源代码,并且这个插件不支持通配符替换,所以我不能说*.thrift。
我使用执行任务来生成源代码并将它们复制到 src 目录。我定义了以下插件
<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 文件并生成源。有办法做到吗?
最佳答案
也许你可以检查 maven-thrift-plugin 是否有帮助吗?
关于java - 循环遍历maven中的特定资源文件生成源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6903097/