OK, I finally figured out how to do this.
Basically, I run the compiler at different stages of the assembly, so that compilation takes place at the source-generation phase, the code is generated at the process sources phase, and finally the compiler does the final compilation at the “compile” stage.
Here is my configuration:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>generateCode</id>
<phase>process-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>my.code.Generator</mainClass>
<arguments>
<argument>-target</argument>
<argument>${project.build.directory}/generated-sources/java</argument>
<argument>-source</argument>
<argument>my.code.generator.Configuration</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>process-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>generate-sources</phase>
</execution>
<execution>
<id>build-generated-code</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<generatedSourcesDirectory>${project.build.directory}/generated-sources/java</generatedSourcesDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Hope this will be helpful to someone.
, , . , "" / "" .