Maven Exec Plugin supports the following two goals:
- exec: to execute external programs (including Java) in a separate process
- java: to execute Java programs in the same JVM
Maven AntRun Plugin supports only one goal:
- run: to execute the Ant target specified
If you have a requirement to run a command-line tool, e.g. cURL, in an asynchronous (non-blocking) way, you can use the Maven Exec Plugin (exec goal). However, in case you need to run it in a synchronous (blocking) way, you can use the Maven AntRun Plugin. You might want to consider something like this before executing the integration tests which could be dependent on the database being in a clean state.
Here is an example:
- Using Maven Exec Plugin
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>drop DB => db_name</id> <phase>pre-integration-test</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>curl</executable> <arguments> <argument>-s</argument> <argument>-S</argument> <argument>-X</argument> <argument>DELETE</argument> <argument>http://${db.server}:${db.port}/db_name</argument> </arguments> </configuration> </execution> </executions> </plugin>
- Using Maven AntRun Plugin
<plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>drop DB => db_name</id> <phase>pre-integration-test</phase> <configuration> <target> <exec executable="curl"> <arg value="-s" /> <arg value="-S" /> <arg value="-X" /> <arg value="DELETE" /> <arg value="http://${db.server}:${db.port}/db_name" /> </exec> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
No comments :
Post a Comment