简体   繁体   English

使用 build-helper-maven-plugin 添加生成的 Apache Avro 源

[英]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.

相关问题 build-helper-maven-plugin 添加额外的源 - build-helper-maven-plugin adding additional source build-helper-maven-plugin add-test-resource错误 - build-helper-maven-plugin add-test-resource error build-helper-maven-plugin导致AnnotationTypeMismatchException - build-helper-maven-plugin causing AnnotationTypeMismatchException 错误:生命周期配置未涵盖插件执行:org.codhaus.mojo:build-helper-maven-plugin:1.3:add-source - Error: plugin execution not covered by life cycle configuration:org.codhaus.mojo:build-helper-maven-plugin:1.3:add-source build-helper-maven-plugin目标:正则表达式属性如何访问生成的属性 - build-helper-maven-plugin goal:regex-property how to access generated property 停止m2e以创建在build-helper-maven-plugin中指定的不存在的源文件夹 - Stopping m2e to create non-existing source folders specified in build-helper-maven-plugin 使用 build-helper-maven-plugin 从 Jar 中排除文件 - Excluding Files From Jar With build-helper-maven-plugin Maven build-helper-maven-plugin 正则表达式无法使用属性作为dependency.version - Maven build-helper-maven-plugin regex unable to use property as dependency.version maven不会识别来自build-helper-maven-plugin的execution'a标签 - maven doesnt recognize execution'a tag from build-helper-maven-plugin Maven | 如何在Gradle中使用build-helper-maven-plugin? - Maven | How can I use build-helper-maven-plugin in Gradle?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM