Reputation: 2385
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:
What happens when you build project B is that Maven will:
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.
Upvotes: 0
Views: 304
Reputation: 298898
I use Groovy for situations like that, but if you don't want to, then having two separate projects is the correct thing to do.
And I would not compile one project from the other, I would just leave them as separate projects. Usually the code generator project won't change as often as the "real" project, so there's no need to build it all the time.
Upvotes: 2