Skip to content

Commit

Permalink
[JENKINS-31851] Windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelrezend committed Jan 22, 2016
1 parent 99df73b commit 5bfb808
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/main/java/jenkins/plugins/play/PlayBuilder.java
Expand Up @@ -88,17 +88,18 @@ public final PlayVersion getPlayVersion() {
* Get the complete path of the Play! executable. First looks for a 'play' executable, then 'activator'.
*
* @param playToolHome Path of the Play tool home.
* @param fileExtension Usually .bat for Windows. No extensions for Unix.
* @return the Play! executable path.
*/
public static File getPlayExecutable(String playToolHome) {
public static File getPlayExecutable(String playToolHome, String fileExtension) {

// Try play executable first
File playExecutable = new File(playToolHome + "/play");
File playExecutable = new File(playToolHome + "/play" + fileExtension);
if (playExecutable.exists())
return playExecutable;

// Try activator executable
playExecutable = new File(playToolHome + "/activator");
playExecutable = new File(playToolHome + "/activator" + fileExtension);
if (playExecutable.exists())
return playExecutable;

Expand Down Expand Up @@ -227,7 +228,8 @@ public void perform(Run<?, ?> run, FilePath filepath, Launcher launcher,
TaskListener listener) throws InterruptedException, IOException {

// Create file from play path String
File playExecutable = PlayBuilder.getPlayExecutable(this.playToolHome);
String fileExtension = launcher.isUnix() ? "" : ".bat";
File playExecutable = PlayBuilder.getPlayExecutable(this.playToolHome, fileExtension);

filepath = new FilePath(filepath, projectPath);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jenkins/plugins/play/version/Play2x.java
Expand Up @@ -67,7 +67,7 @@ public FormValidation doValidateProject(
@QueryParameter String playToolHome,
@QueryParameter String projectPath) {

File playFile = PlayBuilder.getPlayExecutable(playToolHome);
File playFile = PlayBuilder.getPlayExecutable(playToolHome, "");

// If the field is empty or invalid, silently return OK, because the
// validation is already performed by the doCheckProjectPath method in PlayBuilder.
Expand Down
Expand Up @@ -83,7 +83,7 @@ public void Play2x() throws Exception {
// Mock the function to retrieve the play executable, should return a file even if the play executable does not exist
PowerMockito.mockStatic(PlayBuilder.class);
// Play command isn't expected to exist in the test environment. Therefore call the echo command instead.
Mockito.when(PlayBuilder.getPlayExecutable(Mockito.anyString())).thenReturn(new File("echo"));
Mockito.when(PlayBuilder.getPlayExecutable(Mockito.anyString(),Mockito.anyString())).thenReturn(new File("echo"));

FreeStyleProject project = j.createFreeStyleProject();
project.getBuildersList().add(new PlayBuilder(playFolder, projectFolder, play2x));
Expand Down Expand Up @@ -125,7 +125,7 @@ public void Play1x() throws Exception {
// Mock the function to retrieve the play executable, should return a file even if the play executable does not exist
PowerMockito.mockStatic(PlayBuilder.class);
// Play command isn't expected to exist in the test environment. Therefore call the echo command instead.
Mockito.when(PlayBuilder.getPlayExecutable(Mockito.anyString())).thenReturn(new File("echo"));
Mockito.when(PlayBuilder.getPlayExecutable(Mockito.anyString(),Mockito.anyString())).thenReturn(new File("echo"));

FreeStyleProject project = j.createFreeStyleProject();
project.getBuildersList().add(new PlayBuilder(playFolder, projectFolder, play1x));
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/jenkins/plugins/play/TestGenerateCommands.java
Expand Up @@ -26,8 +26,6 @@
import jenkins.plugins.play.version.Play2x;

import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
Expand Down

0 comments on commit 5bfb808

Please sign in to comment.