Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 320
David Camilleri Avatar asked Apr 17 '12 10:04

David Camilleri


People also ask

What does Mvn exec exec do?

Maven exec plugin allows us to execute system and Java programs from the maven command. There are two goals of the maven exec plugin: exec:exec - can be used to execute any program in a separate process. exec:java - can be used to run a Java program in the same VM.

What is Mvn exec Java?

mvn exec:java is a goal from the exec plugin for maven. It lets you specify a main class to execute (see pom. xml). This lets you avoid having to figure out the proper java command to run and classpath arguments and the like.


1 Answers

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.

like image 165
khmarbaise Avatar answered Sep 29 '22 19:09

khmarbaise