Apache

Docs Plugins

Invoker Plugin 3.10.1 · Other versions

The Maven Invoker Plugin is used to run a set of Maven projects. The plugin can determine whether each project execution is successful, and optionally can verify the output generated from a given project execution.

Source
Edit this page
Wrong?
Report a problem

Accessing Test Classes

In case your pre-/post-build scripts perform complex operations that you would rather like to refactor out into some utility class instead of copy&pasting them in each script, you can use the parameter addTestClassPath:

<project>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-invoker-plugin</artifactId>
        <version>3.10.1</version>
        <configuration>
          <addTestClassPath>true</addTestClassPath>
        </configuration>
        <executions>
          <execution>
            <id>integration-test</id>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Setting addTestClassPath to true will prepend the directories ${project.build.testOutputDirectory}, ${project.build.outputDirectory} and all dependencies of your project to the class path of the script interpreter. Among others, this allows you to create some utility classes in your test source tree and use this code for the hook scripts.

Note: Of course, this requires your test classes to be compiled before running the integration tests but this is usually the case if you employ the Invoker Plugin during the lifecycle phase integration-test.