java - 如何向 Maven 插件添加特定配置

标签 java eclipse maven protocol-buffers

在我的 pom.xml 中,我配置了一个插件来将某些 Protobuf 文件转换为 Java 类文件。它看起来像这样:

<plugin>
        <groupId>com.github.igor-petruk.protobuf</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>0.5.3-SNAPSHOT</version>
        <executions>
                 <execution>
                         <goals>
                                 <goal>run</goal>
                         </goals>
                 </execution>
        </executions>
        <configuration>
              <protocCommand>${basedir}/protoc/bin/protoc</protocCommand>
              <inputDirectories>
                    <inputDirectory>proto</inputDirectory>
              </inputDirectories>
        </configuration>
</plugin>

从此 Maven 生成具有以下条目的 .classpath 文件:

<classpathentry kind="src" output="target/classes" path="target/generated-sources/protobuf">
    <attributes>
        <attribute name="optional" value="true"/>
        <attribute name="maven.pomderived" value="true"/>
    </attributes>
</classpathentry>

我现在希望 Maven 做的是向该类路径条目添加一个额外的“属性”条目,以便该条目看起来像这样:

<classpathentry kind="src" output="target/classes" path="target/generated-sources/protobuf">
    <attributes>
        <attribute name="optional" value="true"/>
        <attribute name="maven.pomderived" value="true"/>
        <attribute name="ignore_optional_problems" value="true"/>
    </attributes>
</classpathentry>

这样我就不会从该部分代码中收到警告。

目前我只是不知道该怎么做。我必须编辑哪些文件或其他设置?我可以在 Eclipse 的哪个位置执行此操作?
但这或多或少是关于如何修改 Maven 以包含自定义条目的一般性问题,因为我们有更多的地方想要添加自定义内容。

最佳答案

Login and vote for this Feature-Request:

已有补丁,完善一下

关于java - 如何向 Maven 插件添加特定配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19407624/

相关文章:

java - servlet 过滤器是否必须在 web.xml 文件中指定?

java - Maven 在 POM 中禁用工作区解析

java - 在eclipse中编译java程序

maven - 是否可以用变量定义 Maven 目标?

java - 如何在 Swing 中全局设置应用程序的图标?

java - 在 Java 中解析 XML 文档时处理特定行

java - 线程 "main"java.lang.NoClassDefFoundError : org/openqa/selenium/WebDriver 中的异常

java - 使用 tomcat7-maven-plugin 部署 Tomcat 失败,错误为 "Cannot invoke Tomcat manager: Connection reset by peer: socket write error"

Java 11 字符串连接性能对比 Java 8

java - 如何使用 JDBC 修复 SQL 服务器中的端口 1433 失败错误,我尝试了所有方法