1 37 90 package net.sourceforge.cruisecontrol.util; 91 92 import java.io.File ; 93 import java.io.IOException ; 94 95 import org.apache.log4j.Logger; 96 97 104 public class EnvCommandline extends Commandline { 105 106 private static final Logger LOG = Logger.getLogger(EnvCommandline.class); 107 108 112 private OSEnvironment env = new OSEnvironment(); 113 114 120 public EnvCommandline(String command) { 121 super(command); 122 } 123 124 127 public EnvCommandline() { 128 super(); 129 } 130 131 140 public void setVariable(String var, String value) { 141 env.add(var, value); 142 } 143 144 153 public String getVariable(String var) { 154 return env.getVariable(var); 155 } 156 157 160 public Process execute() throws IOException { 161 Process process; 162 163 File workingDir = getWorkingDir(); 165 if (workingDir == null) { 166 LOG.debug("Executing \"" + this + "\""); 167 process = Runtime.getRuntime().exec(getCommandline(), env.toArray()); 168 } else { 169 LOG.debug( 170 "Executing \"" 171 + this 172 + "\" in directory " 173 + workingDir.getAbsolutePath()); 174 process = Runtime.getRuntime().exec(getCommandline(), env.toArray(), workingDir); 175 } 176 177 return process; 178 } 179 } 180 | Popular Tags |