Skip to content

Commit

Permalink
Fix JENKINS-9538
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed May 13, 2012
1 parent 24fc1df commit ec94333
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/gradle/Gradle.java
Expand Up @@ -147,7 +147,7 @@ private boolean performTask(boolean dryRun, AbstractBuild<?, ?> build, Launcher
ai = ai.forEnvironment(env);
String exe;
if (useWrapper) {
exe = ai.getWrapperExecutable(launcher, build);
exe = ai.getWrapperExecutable(build);
} else {
exe = ai.getExecutable(launcher);
}
Expand Down
22 changes: 9 additions & 13 deletions src/main/java/hudson/plugins/gradle/GradleInstallation.java
Expand Up @@ -3,6 +3,7 @@
import hudson.*;
import hudson.model.*;
import hudson.remoting.Callable;
import hudson.remoting.VirtualChannel;
import hudson.slaves.NodeSpecific;
import hudson.tools.ToolDescriptor;
import hudson.tools.ToolInstallation;
Expand Down Expand Up @@ -68,13 +69,15 @@ public String call() throws IOException {
});
}

public String getWrapperExecutable(Launcher launcher, final AbstractBuild<?, ?> build)
public String getWrapperExecutable(final AbstractBuild<?, ?> build)
throws IOException, InterruptedException {
return launcher.getChannel().call(new Callable<String, IOException>() {
public String call() throws IOException {
File exe = getWrapperExeFile(build);
if (exe.exists()) {
return exe.getPath();
return build.getModuleRoot().act(new FilePath.FileCallable<String>() {
@Override
public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
String execName = (Functions.isWindows()) ? WINDOWS_GRADLE_WRAPPER_COMMAND : UNIX_GRADLE_WRAPPER_COMMAND;
File execFile = new File(f, execName);
if (execFile.exists()) {
return execFile.getPath();
}
return null;
}
Expand All @@ -87,13 +90,6 @@ private File getExeFile() {
return new File(antHome, "bin/" + execName);
}

private File getWrapperExeFile(AbstractBuild<?, ?> build) {
String execName = (Functions.isWindows()) ? WINDOWS_GRADLE_WRAPPER_COMMAND : UNIX_GRADLE_WRAPPER_COMMAND;
return new File(build.getModuleRoot().getRemote(), execName);
}

private static final long serialVersionUID = 1L;

public GradleInstallation forEnvironment(EnvVars environment) {
return new GradleInstallation(getName(), environment.expand(gradleHome), getProperties().toList());
}
Expand Down

0 comments on commit ec94333

Please sign in to comment.