Loop through specific resource files in maven to generate sources

假装没事ソ 提交于 2019-12-19 11:22:48

问题


I use maven-antrun-plugin to generate sources from thrift IDL.

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.

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>

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?


回答1:


Perhaps you could check if maven-thrift-plugin helps?



来源:https://stackoverflow.com/questions/6903097/loop-through-specific-resource-files-in-maven-to-generate-sources

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!