/** * Build up the environment variables toward the Maven launch. */ protected void buildEnvVars(EnvVars env, MavenInstallation mi) throws IOException, InterruptedException { if(mi!=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) mi.buildEnvVars(env); } // 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"); String jvmOptions = env.expand(this.jvmOptions); if(jvmOptions!=null) env.put("MAVEN_OPTS",jvmOptions.replaceAll("[\t\r\n]+"," ")); }
mavenInstallation.buildEnvVars(envOverride); mvnExecPath = mavenInstallation.getExecutable(launcher);
/** * Build up the environment variables toward the Maven launch. */ protected void buildEnvVars(EnvVars env, MavenInstallation mi) throws IOException, InterruptedException { if(mi!=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) mi.buildEnvVars(env); } // 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"); String jvmOptions = env.expand(this.jvmOptions); if(jvmOptions!=null) env.put("MAVEN_OPTS",jvmOptions.replaceAll("[\t\r\n]+"," ")); }
mvn.buildEnvVars(envs);
private String obtainMvnExecutableFromMavenInstallation(String mavenInstallationName) throws IOException, InterruptedException { MavenInstallation mavenInstallation = null; for (MavenInstallation i : getMavenInstallations()) { if (mavenInstallationName.equals(i.getName())) { mavenInstallation = i; LOGGER.log(Level.FINE, "Found maven installation {0} with installation home {1}", new Object[]{mavenInstallation.getName(), mavenInstallation.getHome()}); break; } } if (mavenInstallation == null) { throw new AbortException("Could not find specified Maven installation '" + mavenInstallationName + "'."); } Node node = getComputer().getNode(); if (node == null) { throw new AbortException("Could not obtain the Node for the computer: " + getComputer().getName()); } mavenInstallation = mavenInstallation.forNode(node, listener).forEnvironment(env); mavenInstallation.buildEnvVars(envOverride); console.println("[withMaven] using Maven installation '" + mavenInstallation.getName() + "'"); String mvnExecPath = mavenInstallation.getExecutable(launcher); return mvnExecPath; }
/** * Exposes {@code MAVEN_OPTS} to forked processes. * * <p> * See {@link MavenModuleSetBuild#getEnvironment(TaskListener)} for discussion. */ @Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars envs = super.getEnvironment(log); // 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.getParent().getMaven(); if (mvn == null) throw new hudson.AbortException(Messages.MavenModuleSetBuild_NoMavenConfigured()); mvn = mvn.forEnvironment(envs).forNode(Computer.currentComputer().getNode(), log); mvn.buildEnvVars(envs); return envs; }