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

查看:70
本文介绍了在 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.

我尝试使用以下 tasks.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 文件出现在/target 文件夹中.这表明tasks.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.

在 tasks.json 文件中,将通配符替换为/src 文件夹中单个 .java 文件的名称.结果:VS Code 任务完美运行,并在/target 文件夹中生成一个 .class 文件.这表明tasks.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?

推荐答案

我也遇到过,显然是个bug.目前有一个新的终端运行器可以修复这个错误.尝试将任务 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天全站免登陆