You can use the maven-antrun-plugin plugin to run an arbitrary Ant task or even any program from the command line:
<build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <configuration> <tasks> <exec executable="ls"> <arg value="-l"/> <arg value="-a"/> </exec> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
In this configuration, your command line program will run before compilation, so the generated Java sources will be available to the rest of the code.
source share