[FIXED JENKINS-8092]

Set M2_Home for maven builds and add maven to the path so if the build
needs to run maven from maven (or maven from ant from maven) it can.
This commit is contained in:
James Nord committed 2011-02-20 19:06:44 +00:00
1 parent 1908a88bfd
commit b0b06b515b
3 files changed
+29

No files matched your search

@@ -147,6 +147,20 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
String opts = project.getMavenOpts();
if(opts!=null)
envs.put("MAVEN_OPTS", opts);
// We need to add M2_HOME and the mvn binary to the PATH so if Maven
// needs to run Maven it will pick the correct one.
// This can happen if maven calls ANT which itself calls Maven
// or if Maven calls itself e.g. maven-release-plugin
MavenInstallation mvn = project.getMaven();
if (mvn == null)
throw new AbortException(
"A Maven installation needs to be available for this project to be built.\n"
+ "Either your server has no Maven installations defined, or the requested Maven version does not exist.");
mvn = mvn.forEnvironment(envs).forNode(
Computer.currentComputer().getNode(), log);
envs.put("M2_HOME", mvn.getHome());
envs.put("PATH+MAVEN", mvn.getHome() + "/bin");
return envs;
}