生成的源代码不会自动编译或打包。但是,某些 IDE(即 IntelliJ)会将它们显示为源文件夹。
要使生成的源对 Maven 可见,请在您的节点上添加一个add-source
-step :build/plugins
pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/gen-java</source><!-- adjust folder name to your needs -->
</sources>
</configuration>
</execution>
</executions>
</plugin>