java - 循环遍历maven中的特定资源文件生成源

标签 java maven thrift

我使用 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/

相关文章:

maven - Hot 通过cmd禁用buildnumber-maven-plugin

java - maven 正在使用 java 1.7 编译代码,但我希望它使用 1.8 进行编译

java - 用于包装节俭客户端的 Hystrix 替代品?

python-2.7 - 无法在/usr/lib/Python2.7 中创建站点包,它显示 "Operation not permitted"

java - Words Count 输出显示 mapred 而不是 mapreduce

java - <p :fileUpload> always give me null contents

java - Spring - 如何将组件从另一个模块注入(inject)到 SpringBoot 应用程序中

java - 如何删除重复值然后显示唯一值?

java - 无法在项目 Spark-core_2.11 上执行目标

protocol-buffers - 将 Protobuf 定义转换为 Thrift