I need to generate some Java sources that will then be compiled by Maven. The problem is the legacy code that generates those sources is written in Java. The solution (work-around) used was to have:
- project A with the code that generates Java sources
- project B that depends on project A and calls antrun in Maven to execute the classes in project A
What happens when you build project B is that Maven will:
- compile project A (code that generates sources) and do whatever else the pom.xml of project A tells it to do.
- antrun those classes (as requested by the pom.xml of project B) - thus sources will get generated and added to project B
- compile project B sources
This because Antrun requires the classes in project A to already be compiled when it's executed. This is however an ugly solution, and project A and B should actually be just one project. I know I should use:
<phase>generate-sources</phase>
and I saw an example with Groovy (http://blog.retep.org/2009/11/07/using-groovy-to-generate-java-sources-in-maven/), but I would like to know if there's any simpler way to do this while having everything in one project and not having to change the code-generation from Java to groovy or something else.
Thanks.