Skip to content

exec-maven-plugin not wired to exec.main: mvn exec:java fails without child-POM override #13

Description

@Bonajo

Problem

The exec.main property is used in informaticspom to set the Main-Class in the JAR and assembly manifests, but it is not wired into the exec-maven-plugin's mainClass parameter. As a result, running mvn exec:java in a child project fails with:

The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:3.6.3:java are missing or invalid

Even when exec.main is correctly set in the child pom.xml, the exec plugin ignores it because the plugin's user property is exec.mainClass, not exec.main.

Expected behaviour

Setting <exec.main>com.example.Main</exec.main> in a child project should be sufficient to run mvn exec:java (and optionally mvn exec:java -Dexec.args="...") without any additional plugin configuration.

Suggested fix

Add an exec-maven-plugin configuration block in the parent POM's <build><plugins> section that maps the existing exec.main property to the plugin's mainClass parameter:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <configuration>
        <mainClass>${exec.main}</mainClass>
    </configuration>
</plugin>

This is a non-breaking change: child projects that already override the exec plugin configuration are unaffected, and those that only set exec.main will start working as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions