exec-maven-plugin exec:java failing: Cannot assign configuration values to array of type java.lang.String

StackOverflow https://stackoverflow.com/questions/10189504

  •  01-06-2021
  •  | 
  •  

質問

When executing mvn exec:java it fails to correctly parse the configuration arguments, throwing the following error:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project autotest-programmes: Unable to parse configuration of mojo org.codehaus.mojo:exec-maven-plugin:1.2.1:java: Cannot assign configuration values to array of type java.lang.String: [-classpath, Classpath {}, --glue, com.company.test.cucumber, --format, pretty, --format, html:C:\workspace\autotest\target] -> [Help 1]

This is the plugin configuration used (using Apache Maven 3.0.3):

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <goals>
                <goal>java</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <includeProjectDependencies>false</includeProjectDependencies>
        <includePluginDependencies>true</includePluginDependencies>
        <executableDependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
        </executableDependency>
        <mainClass>cucumber.cli.Main</mainClass>
        <commandlineArgs>-Dfile.encoding=UTF-8</commandlineArgs>
        <arguments>
            <argument>-classpath</argument>
            <classpath/>
            <argument>--glue</argument>
            <argument>com.company.test.cucumber</argument>
            <argument>--format</argument>
            <argument>pretty</argument>
            <argument>--format</argument>
            <argument>html:${project.basedir}\target</argument>
        </arguments>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.0.2</version>
        </dependency>
    </dependencies>
</plugin>
役に立ちましたか?

解決

I would suggest to remove the empty entries from your configuration and try it again.

 <argument>-classpath</argument>
 <classpath/>

Cause in java goal the classpath is not allowed based on the documentation.

BTW: Never use "\" in your maven pom. Use forward slashes instead.

他のヒント

According to exec:java Docs here, you have to :

Remove <arguments> part

And use <additionalClasspathElements> declarations to define a classpath.

If you want to use <classpath/>, you have to use exec:exec and not exec:java. You also have to add the executable, which is java in your case:

<executable>java</executable>

If I understand it correctly, exec:java automatically adds the classpath you cannot override it. The arguments are added after the main class. exec:exec is more generic, it executes any executable with any arguments, one of which can be the <classpath/>.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top