本文整理汇总了Java中com.intellij.execution.configurations.GeneralCommandLine.setWorkDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java GeneralCommandLine.setWorkDirectory方法的具体用法?Java GeneralCommandLine.setWorkDirectory怎么用?Java GeneralCommandLine.setWorkDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.configurations.GeneralCommandLine
的用法示例。
在下文中一共展示了GeneralCommandLine.setWorkDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProcessOutput
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
@NotNull
public static ProcessOutput getProcessOutput(final int timeout, @NotNull final String workDir,
@NotNull final String exePath,
@NotNull final String... arguments) throws ExecutionException {
if (!new File(workDir).isDirectory()
|| (!new File(exePath).canExecute()
&& !exePath.equals("java"))) {
return new ProcessOutput();
}
final GeneralCommandLine cmd = new GeneralCommandLine();
cmd.setWorkDirectory(workDir);
cmd.setExePath(exePath);
cmd.addParameters(arguments);
return execute(cmd, timeout);
}
示例2: configureCommandLine
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
protected GeneralCommandLine configureCommandLine(GeneralCommandLine commandLine) {
final LuaRunConfiguration configuration = (LuaRunConfiguration) runConfiguration;
commandLine.getParametersList().addParametersString(configuration.getInterpreterOptions());
if (!StringUtil.isEmptyOrSpaces(configuration.getWorkingDirectory())) {
commandLine.setWorkDirectory(configuration.getWorkingDirectory());
}
if (!StringUtil.isEmptyOrSpaces(configuration.getScriptName())) {
commandLine.addParameter(configuration.getScriptName());
}
commandLine.getParametersList().addParametersString(configuration.getScriptParameters());
return commandLine;
}
示例3: lint
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
@NotNull
public static ProcessOutput lint(@NotNull String cwd, @NotNull String file, @NotNull String stylintExe, @Nullable String config) throws ExecutionException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setWorkDirectory(cwd);
commandLine.setExePath(stylintExe);
commandLine.addParameter(file);
commandLine.addParameter("--reporter");
commandLine.addParameter("stylint-json-reporter");
if (StringUtils.isNotEmpty(config)) {
commandLine.addParameter("--config");
commandLine.addParameter(config);
}
return NodeRunner.execute(commandLine, TIME_OUT);
}
示例4: setWorkingDirectory
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
protected void setWorkingDirectory(@NotNull final GeneralCommandLine cmd) {
final String workingDirectory = myConfiguration.getWorkingDirectory();
if (!StringUtil.isEmptyOrSpaces(workingDirectory)) {
cmd.withWorkDirectory(workingDirectory);
}
else if (myConfiguration instanceof AbstractPythonTestRunConfiguration) {
final String folderName = ((AbstractPythonTestRunConfiguration)myConfiguration).getFolderName();
if (!StringUtil.isEmptyOrSpaces(folderName)) {
cmd.withWorkDirectory(folderName);
}
else {
final String scriptName = ((AbstractPythonTestRunConfiguration)myConfiguration).getScriptName();
if (StringUtil.isEmptyOrSpaces(scriptName)) return;
final VirtualFile script = LocalFileSystem.getInstance().findFileByPath(scriptName);
if (script == null) return;
cmd.withWorkDirectory(script.getParent().getPath());
}
}
if (cmd.getWorkDirectory() == null) { // If current dir still not set, lets use project dir
cmd.setWorkDirectory(myConfiguration.getWorkingDirectorySafe());
}
}
示例5: createAndSetupCmdLine
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
/**
* Creates process builder and setups it's commandLine, working directory, environment variables
*
* @param workingDir Process working dir
* @param executablePath Path to executable file
* @param arguments Process commandLine @return process builder
*/
public static GeneralCommandLine createAndSetupCmdLine(@Nullable final String workingDir,
@Nullable final Map<String, String> userDefinedEnv,
final boolean passParentEnv,
@NotNull final String executablePath,
@NotNull final String... arguments) {
GeneralCommandLine cmdLine = new GeneralCommandLine();
cmdLine.setExePath(toSystemDependentName(executablePath));
if (workingDir != null) {
cmdLine.setWorkDirectory(toSystemDependentName(workingDir));
}
cmdLine.addParameters(arguments);
cmdLine.withParentEnvironmentType(passParentEnv ? ParentEnvironmentType.CONSOLE : ParentEnvironmentType.NONE);
cmdLine.withEnvironment(userDefinedEnv);
//Inline parent env variables occurrences
EnvironmentUtil.inlineParentOccurrences(cmdLine.getEnvironment());
return cmdLine;
}
示例6: GitHandler
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
/**
* A constructor
*
* @param project a project
* @param directory a process directory
* @param command a command to execute (if empty string, the parameter is ignored)
*/
protected GitHandler(@NotNull Project project, @NotNull File directory, @NotNull GitCommand command) {
myProject = project;
myCommand = command;
myAppSettings = GitVcsApplicationSettings.getInstance();
myProjectSettings = GitVcsSettings.getInstance(myProject);
myEnv = new HashMap<String, String>(EnvironmentUtil.getEnvironmentMap());
myVcs = ObjectUtils.assertNotNull(GitVcs.getInstance(project));
myWorkingDirectory = directory;
myCommandLine = new GeneralCommandLine();
if (myAppSettings != null) {
myCommandLine.setExePath(myAppSettings.getPathToGit());
}
myCommandLine.setWorkDirectory(myWorkingDirectory);
if (GitVersionSpecialty.CAN_OVERRIDE_GIT_CONFIG_FOR_COMMAND.existsIn(myVcs.getVersion())) {
myCommandLine.addParameters("-c", "core.quotepath=false");
}
myCommandLine.addParameter(command.name());
myStdoutSuppressed = true;
mySilent = myCommand.lockingPolicy() == GitCommand.LockingPolicy.READ;
}
示例7: ShellCommand
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
public ShellCommand(@Nullable List<String> commandLine, @Nullable String dir, @Nullable Charset charset) {
if (commandLine == null || commandLine.isEmpty()) {
throw new IllegalArgumentException("commandLine is empty");
}
myCommandLine = new GeneralCommandLine(commandLine);
if (dir != null) {
myCommandLine.setWorkDirectory(new File(dir));
}
if (charset != null) {
myCommandLine.setCharset(charset);
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
//ignore all hg config files except current repository config
myCommandLine.getEnvironment().put("HGRCPATH", "");
}
}
示例8: executeShell
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
/**
* 执行shell
*
* @param shell
*/
public void executeShell(String shell, String workDirectory) {
GeneralCommandLine commandLine =RNPathUtil.createFullPathCommandLine(shell, workDirectory);
commandLine.setWorkDirectory(workDirectory);
myGeneralCommandLine = commandLine;
try {
processCommandline(commandLine);
} catch (ExecutionException e) {
NotificationUtils.showNotification("Unable to run the commandline:" + e.getMessage(),
NotificationType.WARNING);
}
}
示例9: executeRawShell
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
/**
* Execute raw commands without any path or param modify.
*
* @param shell
*/
public void executeRawShell(String workDirectory, String[] shell) {
GeneralCommandLine commandLine =new GeneralCommandLine(shell);
commandLine.setWorkDirectory(workDirectory);
myGeneralCommandLine = commandLine;
try {
processCommandline(commandLine);
} catch (ExecutionException e) {
NotificationUtils.showNotification("Unable to run the commandline:" + e.getMessage(),
NotificationType.WARNING);
}
}
示例10: runGradleCI
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
public static void runGradleCI(Project project, String... params) {
String path = RNPathUtil.getRNProjectPath(project);
String gradleLocation = RNPathUtil.getAndroidProjectPath(path);
if (gradleLocation == null) {
NotificationUtils.gradleFileNotFound();
} else {
GeneralCommandLine commandLine = new GeneralCommandLine();
// ExecutionEnvironment environment = getEnvironment();
commandLine.setWorkDirectory(gradleLocation);
commandLine.setExePath("." + File.separator + "gradlew");
commandLine.addParameters(params);
// try {
//// Process process = commandLine.createProcess();
// OSProcessHandler processHandler = new KillableColoredProcessHandler(commandLine);
// RunnerUtil.showHelperProcessRunContent("Update AAR", processHandler, project, DefaultRunExecutor.getRunExecutorInstance());
// // Run
// processHandler.startNotify();
// } catch (ExecutionException e) {
// e.printStackTrace();
// NotificationUtils.errorNotification("Can't execute command: " + e.getMessage());
// }
// commands process
try {
processCommandline(project, commandLine);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}
示例11: build
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
public static void build(Project project) {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setWorkDirectory(project.getBasePath());
commandLine.setExePath("python");
commandLine.addParameter("freeline.py");
// debug
commandLine.addParameter("-d");
// commands process
try {
processCommandline(project, commandLine);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
示例12: doOKAction
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
@Override
protected void doOKAction() {
Notification notification = new Notification("LaravelStorm",
"Success", "temp content", NotificationType.INFORMATION);
Notification errorNotification = new Notification("LaravelStorm",
"Error", "Could not create file.", NotificationType.ERROR);
GeneralCommandLine cmd = new GeneralCommandLine("php", "artisan");
cmd.setWorkDirectory(project.getBasePath());
cmd.addParameter(artisanCommand);
if (additionCommandCheckBox.isSelected())
cmd.addParameter(optionCmdParameter);
cmd.addParameter(fileName.getText());
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(cmd.createProcess().getInputStream()));
String execResult = reader.readLine();
if (execResult.isEmpty()){
Notifications.Bus.notify(errorNotification, project);
}
else{
notification.setContent(execResult);
Notifications.Bus.notify(notification, project);
}
} catch (ExecutionException | IOException e) {
e.printStackTrace();
}
super.doOKAction();
}
示例13: getProtractorRunCommand
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
private GeneralCommandLine getProtractorRunCommand(@NotNull Config config) {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(config.getProtractorCmdPath());
commandLine.setWorkDirectory(project.getBasePath());
commandLine.addParameter(config.getProtractorConfigJsPath());
StringBuilder specArg = new StringBuilder().append("--specs=").append(config.getFeaturesDirPath()).append("/").append(fileName);
if(icon == SCENARIO_ICON) {
specArg.append(":").append(line + 1);
}
commandLine.addParameter(specArg.toString());
return commandLine;
}
示例14: enableExecution
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
private static void enableExecution(@NotNull final File filePath) {
final GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath("chmod");
commandLine.addParameter("+x");
commandLine.addParameter(filePath.getName());
commandLine.setWorkDirectory(filePath.getParent());
final ExecResult execResult = SimpleCommandLineProcessRunner.runCommand(commandLine, null);
if (execResult.getExitCode() != 0) {
LOG.warn("Failed to set executable attribute for " + filePath + ": chmod +x exit code is " + execResult.getExitCode());
}
}
示例15: enableExecution
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
/**
* Set executable attribute for file.
* @param filePath File to be setted executable attribute
* @param baseDir Directory to be setted Work Directory
*/
private static void enableExecution(@NotNull final String filePath, @NotNull final String baseDir) {
final GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath("chmod");
commandLine.addParameter("+x");
commandLine.addParameter(filePath);
commandLine.setWorkDirectory(baseDir);
final ExecResult execResult = SimpleCommandLineProcessRunner.runCommand(commandLine, null);
if(execResult.getExitCode() != 0) {
Loggers.AGENT.warn("Failed to set executable attribute for " + filePath + ": chmod +x exit code is " + execResult.getExitCode());
}
}