Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add specific configuration to a Maven plugin

In my pom.xml I configure a plugin to convert certain Protobuf files to Java class files. It looks like this:

<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>

Out of this Maven generates the .classpath file with the following entry:

<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>

What I would now like Maven to do is to add an additional "attribute" entry to that classpath entry so that the entry looks like this:

<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>

Like that I won't get warnings from that part of the code.

At the moment I just don't know how to do that. Which files or other settings do I have to edit? Where in Eclipse can I do that?
But this is more or less a general question as to how Maven can be modified to include customized entries, because we have some more spots where we would want to add custom things in.

like image 241
Sebastian Avatar asked Nov 02 '22 12:11

Sebastian


1 Answers

Login and vote for this Feature-Request:

There already is a patch, improve it.

like image 53
Grim Avatar answered Nov 09 '22 08:11

Grim