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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With