I am using Maven Wrapper on Travis because it ships with a super-old version of Maven by default.
The library being built runs integration tests using maven-verifier. The latter forks a JVM to run each integration test using the (outdated) Maven instance installed on the system.
Is there a way to get maven-verifier to use the Maven version provided by Maven Wrapper?
According to the implementation of org.apache.maven.it.Verifier#getMavenLauncher
(at version 1.7.2 when checked), it will attempt to use a Maven wrapper if that wrapper is present in the repository that you are running the test on (not in the project repository that is running the test).
boolean useWrapper = Files.exists(Paths.get(getBasedir(), "mvnw"));
getBasedir()
is the root of the project folder being tested here. I had the same issue and I copied the mvnw
and .mvn
folders into the project I was testing, and it did indeed find the appropriate version of Maven.
My new projects to be tested look like this
default-test-project
|_ .mvn/
|_ mvnw
|_ pom.xml
It's worth mentioning that Verifier#getMavenLauncher
doesn't appear to check for a mvnw.cmd
so this may not work on a Windows machine.