Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions core/src/main/groovy/noe/common/utils/Cmd.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,23 @@ public class Cmd {
*
* @deprecated args
*/
public static int executeCommand(command, File targetDir, Map args = null, Map tmpProps = null) {
return executeCommandRedirectIO(command, targetDir, null, System.out, System.err, args, tmpProps)
static int executeCommand(command, File targetDir, Map args = null, Map tmpProps = null) {

if (command instanceof String || command instanceof GString) {
if (command.length() > 2 && command[0] == "[" && command[command.length() - 1] == "]") {
command = command[1..command.length() - 2]
}
command = command.tokenize(", ")
}

Map rv = executeCommandConsumeStreams(command as List, targetDir, null, 60000L, tmpProps)
if (!rv.stdOut.isEmpty()) {
log.info(rv.stdOut)
}
if (!rv.stdErr.isEmpty()) {
log.trace(rv.stdErr)
}
return rv.exitValue
}

/**
Expand Down
30 changes: 16 additions & 14 deletions core/src/main/groovy/noe/common/utils/JBFile.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import noe.common.Constants
import noe.common.DefaultProperties
import org.apache.commons.io.FileUtils

import java.nio.file.Files
import java.nio.file.Path
import java.util.concurrent.TimeUnit

/**
Expand Down Expand Up @@ -186,21 +188,21 @@ class JBFile {
}

def returnValue = 0
try {
// try to copy with ant
ant.copy(file: src.getAbsolutePath(), tofile: dest.getAbsolutePath(), overwrite: "true")
} catch (e) {
// Try it with sudo rights
if (!platform.isWindows()) {
def args = (preserveRights) ? '-p' : ''
args += (dereference) ? ' -L' : ''
if (useAdminPrivileges) {
returnValue += Cmd.executeSudoCommand("cp -r ${args} ${src.absolutePath} ${dest}", new File('.'))
} else {
returnValue += Cmd.executeCommand("cp -r ${args} ${src.absolutePath} ${dest}", new File('.'))
}
if (platform.isWindows()) {
try {
log.info("Copying ${src.absolutePath} to ${dest.absolutePath}")
dest << src.text
} catch (e) {
log.trace("JBFIle.copyFile failed", e)
returnValue = 2
}
} else {
def args = (preserveRights) ? '-p' : ''
args += (dereference) ? ' -L' : ''
if (useAdminPrivileges) {
returnValue += Cmd.executeSudoCommand("cp -r ${args} ${src.absolutePath} ${dest}", new File('.'))
} else {
returnValue = -1
returnValue += Cmd.executeCommand("cp -r ${args} ${src.absolutePath} ${dest}", new File('.'))
}
}
return returnValue == 0
Expand Down