问题
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