Micronaut exec-maven-plugin 无法将值存储到数组中:ArrayStoreException

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

我正在使用 maven 插件在 generate-sources 阶段修改一些源文件。我总是得到例外:

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

问题是由于在 Micronaut 的父 pom 中使用此插件以及 Maven 将插件的配置部分合并在一起的行为。解决方案是将 combine.self="override" 传递给 arguments 部分。

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

说明:

Micronaut 在其 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>

这里 <classpath/> 引起了问题。 Maven 正在将参数部分合并在一起,尽管这些是不同的目标。这可以用 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>