Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you define both an exec and java goal for maven exec plugin?

I'm trying to do a couple tasks with the maven exec plugin. One is to run a script to generate some external data that the app will use. The second is to run a chunk of java code to do some convenience work during the compile 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 the error:

[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 saying the parameter 'mainClass' is missing or invalid.

like image 850
andematt Avatar asked Aug 16 '12 04:08

andematt


1 Answers

It seems that the problem I was running into was calling out the plugin directly.

exec:exec

Hitting the plugin by calling the phase it's bound to made it work.

mvn clean generate-sources package
like image 140
andematt Avatar answered Sep 28 '22 01:09

andematt