sakra
sakra

Reputation: 65981

Maven exec plugin multiple executions not working

I am trying to make the Maven exec plugin run multiple executions when I invoke the exec:java goal in the following way:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>first</id>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>com.example.First</mainClass>
                    </configuration>
                </execution>
                <execution>
                    <id>second</id>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>com.example.Second</mainClass>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

However upon running mvn exec:java with maven 3.1.1 I get the error message:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project test: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid -> [Help 1]

Running the exec:java goal for a single execution (without using the nested executions element) works as expected.

Upvotes: 1

Views: 1527

Answers (1)

carlspring
carlspring

Reputation: 32707

It seems to me that the problem is that neither of the <execution/> is tied to a particular <phase/>. Try setting one.

Upvotes: 2

Related Questions