Maven Invoker: IllegalStateException

If you're running from a Maven-Surefire unit test then it's best to request that Surefire passes the maven.home system property on to its child processes. Per https://maven.apache.org/shared/maven-invoker/usage.html you can do this by adding the following config stanza:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.4</version> <!-- see surefire-page for available versions -->
        <configuration>
          <systemPropertyVariables>
            <maven.home>${maven.home}</maven.home>
          </systemPropertyVariables>
        </configuration>
      </plugin>
    </plugins>
    ...
  </build>
  ...
</project>

Either set the request.pomFile or request.baseDirectory so the Invoker knows from which directory or file Apache Maven should be executed.

Tags:

Java

Maven