Maven Anti Patterns: Build Helper Maven Plugin

In Maven builds I often see a pattern like the following:

 1<plugins>
 2  <plugin>
 3    <groupId>group</groupId>
 4    <artifactId>generatorPlugin</artifactId>
 5    <version>..</version>
 6    <configuration>
 7     ...
 8    </configuration>
 9  </plugin>
10  <plugin>
11    <groupId>org.codehaus.mojo</groupId>
12    <artifactId>build-helper-maven-plugin</artifactId>
13    <version>...</version>
14    <executions>
15      <execution>
16        <phase>generate-sources</phase>
17        <goals>
18          <goal>add-source</goal>
19        </goals>
20        <configuration>
21          <sources>
22            <source>target/generated-sources/WHATEVER</source>
23          </sources>
24        </configuration>
25      </execution>
26    </executions>
27  </plugin>
28</plugins>

The generatorPlugin is just a placeholder for different kinds of maven plugins which generate code for example ANTLR4 Maven Plugin, Templating Maven Plugin, JAXB2 Maven Plugin just to mention a few examples here.

Usually this can be reduced to the following:

 1<plugins>
 2  <plugin>
 3    <groupId>group</groupId>
 4    <artifactId>generatorPlugin</artifactId>
 5    <version>..</version>
 6    <configuration>
 7     ...
 8    </configuration>
 9  </plugin>
10</plugins>

The reason is simple, cause those plugins already handle the task to add the generated source code to the correct parts in Maven to give for example the Maven Compiler Plugin a hint to compile also those generated java code.

Yes I know there are some of such plugins out there which do not do it in the correct way which means you need to add the Build Helper Maven Plugin snippet, but this means those plugins need some improvements. Those plugins violate the Convention over Configuration paradigm. Why? Simply cause you as user need to think about an internal detail of those plugins which is simply wrong. They have to handle that on their own.

A further note here. I do not say Build Helper Maven Plugin is wrong. It is the usage of the Build Helper Maven Plugin in the described relationship.