De https://area-51.blog/2009/11/07/using-groovy-to-generate-java-sources-in-maven/
Adicione o seguinte ao seu pom.xml
<project>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId> org.codehaus.mojo </groupId>
<artifactId> build-helper-maven-plugin </artifactId>
<executions>
<execution>
<id> add-groovy-sources </id>
<phase> gerar-sources </phase>
<goals>
<goal> add-source </goal>
</goals>
<configuração>
<fontes>
<source> $ {project.build.directory} / generated-sources / groovy </source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId> org.codehaus.groovy.maven </groupId>
<artifactId> gmaven-plugin </artifactId>
<executions>
<execution>
<fase> gerar recursos </phase>
<goals>
<goal> execute </goal>
</goals>
<configuration>
<scriptpath>
<element> $ {basedir} / src / main / script </element>
</scriptpath>
<source>
// O código necessário para iniciar o o arquivo de classe definido vai aqui
MyCodeGenerator mcg = new MyCodeGenerator ()
mcg .generate (project)
</source>
</configuration>
</ execução>
</executions>
</plugin>
</plugins>
<build>
<project>
Então, em $ {basedir} / src / main / script, crie MyCodeGenerator.groovy
class MyCodeGenerator {
static generate (project) {
// Faça suas coisas aqui
}
}