diff --git a/core/src/main/java/hudson/tasks/Maven.java b/core/src/main/java/hudson/tasks/Maven.java index 6f97098adc..ae07baae88 100644 --- a/core/src/main/java/hudson/tasks/Maven.java +++ b/core/src/main/java/hudson/tasks/Maven.java @@ -141,8 +141,17 @@ public class Maven extends Builder { } Map env = build.getEnvVars(); - if(ai!=null) + if(ai!=null) { + // if somebody has use M2_HOME they will get a classloading error + // when M2_HOME points to a different version of Maven2 from + // MAVEN_HOME (as Maven 2 gives M2_HOME priority) + // + // The other solution would be to set M2_HOME if we are calling Maven2 + // and MAVEN_HOME for Maven1 (only of use for strange people that + // are calling Maven2 from Maven1) + env.remove("M2_HOME"); env.put("MAVEN_HOME",ai.getMavenHome()); + } // just as a precaution // see http://maven.apache.org/continuum/faqs.html#how-does-continuum-detect-a-successful-build env.put("MAVEN_TERMINATE_CMD","on");