I've suffered from this problem and found that, for some reason or other, environment variables were simply not being parsed (executing cd %M2%
told me that there was no folder %M2%
in the current directory). In the end adding the explicit path to Maven's executable worked for me:
C:\apache-maven-3.1.0\bin