Can you define both exec and java target for maven exec plugin?

I am trying to complete a couple of tasks using the maven exec plugin. One of them is to run a script to create some external data that the application will use. The second is to run a piece of java code to do some convenience work during the compilation phase.

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
    <execution>
        <id>data_for_app</id>
        <phase>generate-sources</phase>
        <goals>
            <goal>exec</goal>
        </goals>
        <configuration>
            <executable>${basedir}/scripts/getappdata.sh</executable>
            <arguments>
                <argument>${basedir}/src/main/webapp/WEB-INF/xml/appdatahere/</argument>
            </arguments>
        </configuration>
    </execution>
    <execution>
        <id>do_convenience</id>
        <phase>compile</phase>
        <goals>
            <goal>java</goal>
        </goals>
        <configuration>
            <mainClass>com.example.DoConvenienceStuff</mainClass>
            <arguments>
                <argument>https://example.com/data</argument>
            </arguments>
        </configuration>
    </execution>
</executions>
</plugin>

But when I run:

mvn clean package exec:exec

I get an error message:

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

Or a similar error indicating that the mainClass parameter is missing or invalid.

+5
source share
1 answer

It seems that the problem I ran into was causing the plugin directly.

exec:exec

Clicking on the plugin, causing the phase with which it is associated, so that it works.

mvn clean generate-sources package
+13
source

All Articles