[英]Add generated Apache Avro source with build-helper-maven-plugin
我正在使用 Apache avro 生成一些 pojos,所有这些都在运行中运行良好,期望生成的源在 IDE (intellij) 上的导入中被标记为不存在。
我尝试使用 build-helper-maven-plugin 添加源代码,但它不起作用这是我的 maven 配置 apache avro 和构建助手插件:
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
<configuration>
<stringType>String</stringType>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/</outputDirectory>
<imports>
<import>${project.basedir}/src/main/avro/errorkind.avsc</import>
</imports>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
“生成源”位于 ${project.build.directory}/target 文件夹下另外,尝试将“生成源”标记为源目录。 您可以通过以下方式做到这一点:
项目结构→模块→单击生成的源文件夹并将其设为源文件夹。
尝试使用以下内容更改您的 pom 并运行全新安装,然后您应该能够导入。
<configuration>
<sourceDirectory>${project.basedir}/src/main/resources/</sourceDirectory>
<source>${project.build.directory}/generated-sources</source>
</configuration>
在 POM 中,InteliJ 可能会在添加后给你一个假错误,但你的构建会成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.