I have pom.xml with the structure like:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<includes>
... some directories with .java files to compile.
…
<plugin> --- some my plugin that generates one more dir with .java files.
At this point I want to compile the newly generated files, so I repeat here step 1 with different content of “includes” element. Second compilation does not happen at all. Please advice.
Your plugin should run in
generate-sourcesphase. Then you have to make sure that the generated source is available during the normalcompilephase.Your plugin should be configured something like this:
You can directly from your plugin (mojo) add the compilation source path to use.
Here is an example of what you must add to your mojo:
And something like this must be added to your
execute()method:This will output the generated java source files into
target/src-generated/but that can either be changed to some other default value in your mojo OR by adding this to the configuration part of the plugin:The generated java source files will automatically be included in the
compilephase.