Search code examples
javamavenmaven-3maven-surefire-pluginmaven-antrun-plugin

How to execute Maven's antrun between testCompile and test phases (before Surefire executes)?


In my Maven build, I have a small block of Ant code that needs to run right before the Surefire kicks in to perform a few configurations.

The code is executed with antrun, but I can't get antrun to be executed right before Surefire.

Here is the relevant section of the output of my build:

[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ com...tests ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\...\com...tests\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ com...tests ---
[INFO] Surefire report directory: C:\...\com...tests\target\surefire-reports

Basically I need antrun to execute between maven-compiler-plugin:3.1:testCompile and maven-surefire-plugin:2.16:test .

I tried binding the antrun to the test phase and place it before the surefire plugin in the POM file, but it always executes after the Surefire plugin. I also tried to configure it to run in the testCompile phase, and place it after the maven-compiler-plugin plugin, but no success either.. it executes after surefire.

Does anyone know how to get it to execute in between these two??

Thank you!

Eduardo


Solution

  • You can execute the antrun plugin in process-test-classes life-cycle phase which is just between test-compile and test