Generating new sources via Maven plugin after compile phase

Posted by japher on Stack Overflow See other posts from Stack Overflow or by japher
Published on 2011-01-04T15:51:18Z Indexed on 2011/01/04 15:54 UTC
Read the original article Hit count: 497

Filed under:
|
|
|

I have a Maven project within which I need execute two code generation steps. One generates some Java types, then the second depends on those Java types to generate some more code. Is there a way to have both of these steps happening during my build?

At the moment my steps are:

  1. execute first code generation plugin (during generate-sources)
  2. add directory of generated types to build path
  3. execute second code generation plugin (during compile)

However my problem is that anything generated by the second code generation plugin will not be compiled (because the compile phase has finished). If I attach the second code generation plugin to an earlier phase, it fails because it needs the classes from the first code generation plugin to be present on the classpath.

I know I could split this into two modules with one dependent on the other, but I was wondering if this could be achieved in one pom. It seems like a need a way to invoke compile again after the normal compile phase is complete.

Any ideas?

© Stack Overflow or respective owner

Related posts about java

Related posts about code-generation