mavenmicronautexec-maven-plugin

Micronaut exec-maven-plugin Cannot store value into array: ArrayStoreException


I'm using the maven plugin to modify some source files during the generate-sources phase. I always get the exception:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (openapischema-model-description) on project profile-generation: Unable to parse configuration of mojo org.co
dehaus.mojo:exec-maven-plugin:3.0.0:java for parameter arguments: Cannot store value into array: ArrayStoreException -> [Help 1]
 <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>openapischema-model-description</id>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <mainClass>de.ohmesoftware.javadoctoopenapischema.Enricher</mainClass>
                            <includePluginDependencies>true</includePluginDependencies>
                            <arguments>
                                <argument>-sourcePath</argument>
                                <argument>src/main/java/com/gigsky/profile_generation/domain</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>de.ohmesoftware</groupId>
                        <artifactId>javadoctoopenapischema</artifactId>
                        <version>0.0.1</version>
                    </dependency>
                </dependencies>
            </plugin>

Solution

  • The problem results from the usage of this plugin in Micronaut's parent pom and the behavior of Maven to merge together the configuration sections of a plugin. The solution is to pass combine.self="override" to the arguments section.

    <configuration>
        <mainClass> de.ohmesoftware.javadoctoopenapischema.Enricher</mainClass>
        <includePluginDependencies>true</includePluginDependencies>
        <arguments combine.self="override">
            <argument>-sourcePath</argument>
           <argument>src/main/java/com/gigsky/profile_generation/domain</argument>
        </arguments>
    </configuration>
    

    Explanantion:

    Micronaut is defining in its micronaut-parent-2.0.0.pom:

    <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <version>1.6.0</version>
              <configuration>
                <executable>java</executable>
                <arguments>
                  <argument>-classpath</argument>
                  <classpath/>
                  <argument>-XX:TieredStopAtLevel=1</argument>
                  <argument>-Dcom.sun.management.jmxremote</argument>
                  <argument>${exec.mainClass}</argument>
                </arguments>
              </configuration>
            </plugin>
    

    Here <classpath/> is causing problems. Maven is merging the arguments section together, although these are different goals. This can be inspected with mvn help:effective-pom:

    <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
              <execution>
                <id>openapischema-model-description</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>java</goal>
                </goals>
                <configuration>
                  <mainClass>de.ohmesoftware.javadoctoopenapischema.Enricher</mainClass>
                  <includePluginDependencies>true</includePluginDependencies>
                  <arguments>
                    <argument>-sourcePath</argument>
                    <argument>src/main/java/com/gigsky/profile_generation/domain</argument>
                    <classpath />
                  </arguments>
                  <executable>java</executable>
                </configuration>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>de.ohmesoftware</groupId>
                <artifactId>javadoctoopenapischema</artifactId>
                <version>0.0.1</version>
                <scope>compile</scope>
              </dependency>
            </dependencies>
            <configuration>
              <executable>java</executable>
              <arguments>
                <argument>-classpath</argument>
                <classpath />
                <argument>-XX:TieredStopAtLevel=1</argument>
                <argument>-Dcom.sun.management.jmxremote</argument>
                <argument>com.gigsky.profile_generation.Application</argument>
              </arguments>
            </configuration>
          </plugin>