1

Getting this error in child pom.xml for module libs

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (install-uum) on project libs: Command execution failed. Cannot run program "mvn" (in directory "D:\xyz\build\project_name\Build\app_name\libs"): CreateProcess error=2, The system cannot find the file specified

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>install-uum</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>install:install-file</argument>
<argument>-Dfile=${basedir}/entity-service-1.0.0.jar</argument>
<argument>-DgroupId=com.xyz.app</argument>
<argument>-DartifactId=entity-service</argument>
<argument>-Dversion=1.0.0</argument>
<argument>-Dpackaging=jar</argument>
</arguments>
</execution>

Looks like the maven is not set in the path. Is there any way I can setup maven executable in the PATH from pom.xml instead of doing set PATH=%M2_HOME%\bin;%PATH% from command line?

jjmartinez
  • 779
  • 5
  • 20
  • 37
user3199100
  • 61
  • 1
  • 3
  • 6
  • Why would you want this? It's more common to put this in your environment. But maybe [this](http://stackoverflow.com/questions/14027003/how-to-set-up-an-environment-variable-in-mvn-pom) is what you are looking for... – mmjmanders Mar 11 '14 at 14:18
  • yes I am looking for pom.xml to put m2_home in the path at build time. – user3199100 Mar 11 '14 at 15:18
  • Why would you like to execute maven via exec-maven-plugin? – khmarbaise Mar 11 '14 at 16:16

1 Answers1

3

Setting the M2_HOME variable in your environment to match the location of the Maven installation should be enough

Or just:

  • include the absolute path to your maven installation bin directory
  • add the ".bat" extension
<executable>"path to your maven installation"\bin\mvn.bat</executable>
Pedro
  • 692
  • 8
  • 24