[英]Add generated Apache Avro source with build-helper-maven-plugin
I'm using Apache avro to generate some pojos, all work very well in run, expect that the generated source is marked as inexistent in imports on IDE (intellij).我正在使用 Apache avro 生成一些 pojos,所有这些都在运行中运行良好,期望生成的源在 IDE (intellij) 上的导入中被标记为不存在。
I tried to use build-helper-maven-plugin to add source, but it doesn't work this is my maven configuration for apache avro and build helper plugins:我尝试使用 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>
"generated-sources" reside under ${project.build.directory}/target folder Also, try marking "generated-sources" as source directory. “生成源”位于 ${project.build.directory}/target 文件夹下另外,尝试将“生成源”标记为源目录。 You can do that by:
您可以通过以下方式做到这一点:
Project Structure → Modules → Click the generated-sources folder and make it a sources folder.项目结构→模块→单击生成的源文件夹并将其设为源文件夹。
Try changing your pom with following and run clean install and then you should be able to import.尝试使用以下内容更改您的 pom 并运行全新安装,然后您应该能够导入。
<configuration>
<sourceDirectory>${project.basedir}/src/main/resources/</sourceDirectory>
<source>${project.build.directory}/generated-sources</source>
</configuration>
In POM InteliJ may give you a fake error after adding this but your build will success.在 POM 中,InteliJ 可能会在添加后给你一个假错误,但你的构建会成功。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.