在Visual Studio Code中的arg中使用通配符的任务命令 [英] Task command using wildcards in arg in Visual Studio Code

查看:139
本文介绍了在Visual Studio Code中的arg中使用通配符的任务命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在OS X Yosemite上使用Visual Studio Code 0.9.2编辑.java文件.

I am using Visual Studio Code 0.9.2 on OS X Yosemite to edit a .java file.

我尝试使用以下task.json文件编译该文件:

I attempt to compile this file using the following tasks.json file:

{
    "version": "0.1.0",
    "command": "javac",
    "isShellCommand": true,
    "echoCommand": true,
    "showOutput": "always",
    "args": ["-d","${workspaceRoot}\/target","${workspaceRoot}\/src\/*.java"]
}

执行此任务会将以下命令回显到输出"窗口:

Executing this task echoes the following command to the Output window:

running command$ javac -d /Users/caoimheboers/Desktop/JLab11/target
/Users/caoimheboers/Desktop/JLab11/src/*.java

...很好,但是随后将任务执行的结果报告为:

... which is fine, however the result of the task execution is then reported as:

javac: file not found: /Users/caoimheboers/Desktop/JLab11/src/*.java
Usage: javac <options> <source files>
use -help for a list of possible options

我尝试了以下操作:

  1. 从输出"窗口复制回显的javac命令(包括所有参数),并将其粘贴到终端"窗口中的命令行. 结果:/src文件夹中的单个.java文件将进行编译,而/class文件夹中将显示一个.class文件. 这表明在task.json文件中,javac命令的语法(包括所有参数)是正确的.

  1. Copy the echoed javac command (including all arguments) from the Output window and paste it to the command line in a Terminal window. Result: The single .java file in the /src folder compiles and a .class file appears in the /target folder. This indicates that the syntax of the javac command (including all arguments) is correct in the tasks.json file.

在task.json文件中,将通配符替换为/src文件夹中单个.java文件的名称. 结果:VS Code任务运行完美,并在/target文件夹中生成一个.class文件. 这表示task.jason文件中有关命令的所有内容都可以,除了通配符.

In the tasks.json file, replace the wildcard character with the name of the single .java file in the /src folder. Result: The VS Code task runs perfectly, and produces a .class file in the /target folder. This indicates that everything about the command in the tasks.jason file is OK except for the wildcard character.

关于我在做什么错的任何想法吗?

Any ideas on what I'm doing wrong?

推荐答案

我也经历过,这显然是一个错误.当前,有一个新的终端运行程序可以修复此错误.尝试将任务JSON模式更改为新的2.0.0版本,重新加载窗口,一切都会好起来:

I also experienced it, it was apparently a bug. Currently there is a new terminal runner which fixes this error. Try to change the tasks JSON schema to new 2.0.0 version, reload the window and everything will be fine:

{
    "version": "2.0.0",
    "command": "javac",
    "isShellCommand": true,
    "echoCommand": true,
    "showOutput": "always",
    "args": ["-d","${workspaceRoot}/target","${workspaceRoot}/src/*.java"]
}

相关问题在这里: https://github.com/Microsoft/vscode/issues/16865

您无需顺便转义斜杠字符.

You don't need to escape the slash character by the way.

这篇关于在Visual Studio Code中的arg中使用通配符的任务命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆