提交 8cad899e 编写于 作者: K kohsuke

Fixed #1185. Try to set the current directory just like CLI maven tends to be run.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6717 71c3de6d-444a-0410-be80-ed276b4c234a
上级 b202afe8
......@@ -346,7 +346,7 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
Map<String,String> envVars = getEnvVars();
ProcessCache.MavenProcess process = mavenProcessCache.get(launcher.getChannel(), listener,
new MavenProcessFactory(getParent().getParent(),launcher,envVars));
new MavenProcessFactory(getParent().getParent(),launcher,envVars,null));
ArgumentListBuilder margs = new ArgumentListBuilder();
margs.add("-N").add("-B");
......
......@@ -2,6 +2,7 @@ package hudson.maven;
import hudson.AbortException;
import hudson.Launcher;
import hudson.FilePath;
import hudson.maven.MavenBuild.ProxyImpl2;
import hudson.FilePath.FileCallable;
import hudson.model.AbstractBuild;
......@@ -250,13 +251,14 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
proxies.put(m.getModuleName(),m.newBuild().new ProxyImpl2(MavenModuleSetBuild.this,slistener));
// run the complete build here
FilePath pom = project.getModuleRoot().child(project.getRootPOM());
Map<String,String> envVars = getEnvVars();
ProcessCache.MavenProcess process = MavenBuild.mavenProcessCache.get(launcher.getChannel(), slistener,
new MavenProcessFactory(project,launcher,envVars));
new MavenProcessFactory(project,launcher,envVars,pom.getParent()));
ArgumentListBuilder margs = new ArgumentListBuilder();
margs.add("-B").add("-f",project.getModuleRoot().child(project.getRootPOM()).getRemote());
margs.add("-B").add("-f", pom.getRemote());
margs.addTokenized(project.getGoals());
Builder builder = new Builder(slistener, proxies, project.sortedActiveModules, margs.toList(), envVars);
......
......@@ -41,10 +41,21 @@ final class MavenProcessFactory implements ProcessCache.Factory {
*/
private final Map<String,String> envVars;
MavenProcessFactory(MavenModuleSet mms, Launcher launcher, Map<String, String> envVars) {
/**
* Optional working directory. Because of the process reuse, we can't always guarantee
* that the returned Maven process has this as the working directory. But for the
* aggregator style build, the process reuse is disabled, so in practice this always works.
*
* Also, Maven is supposed to work correctly regardless of the process current directory,
* so a good behaving maven project shouldn't rely on the current project.
*/
private final FilePath workDir;
MavenProcessFactory(MavenModuleSet mms, Launcher launcher, Map<String, String> envVars, FilePath workDir) {
this.mms = mms;
this.launcher = launcher;
this.envVars = envVars;
this.workDir = workDir;
}
/**
......@@ -55,7 +66,7 @@ final class MavenProcessFactory implements ProcessCache.Factory {
listener.getLogger().println("Using env variables: "+ envVars);
try {
return launcher.launchChannel(buildMavenCmdLine(listener).toCommandArray(),
out, null, envVars);
out, workDir, envVars);
} catch (IOException e) {
if(fixNull(e.getMessage()).contains("java: not found")) {
// diagnose issue #659
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册