运行位于任何地方的 ant 构建文件的 VSCode 任务 [英] VSCode Task to run ant buildfile located anywhere

查看:42
本文介绍了运行位于任何地方的 ant 构建文件的 VSCode 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个跨越多个源目录的庞大项目,该项目是在过去 15 年中开发的,使用 Eclipse 和自定义外部工具配置从源目录中的任何地方的 build.xml 文件启动 ant 任务(我知道这很混乱!).

I have a huge project spread across multiple source directories which was developed the last 15 years using eclipse with custom external tools configurations to launch ant tasks from build.xml files anywhere inside the source directories (a big mess, I know!).

由于日常工作主要是基于 xml 和 JavaScript,我认为 VSCode 是一种轻量级的替代方案(因为 Eclipse 无法在不超过 HeepSpace 的情况下处理大型 xml 文件).Task Runners 在我看来是将 ant 构建集成到编辑器中的好方法,它们也是宣传能够运行 ant 构建:

As the everyday work is mostly xml and JavaScript based, I thought of VSCode as a lightweight alternative (as eclipse is e.g. unable to deal with large xml files without exceeding HeepSpace). Task Runners look to me like a great way to integrate the ant builds into the editor, they are also advertised as capable of running ant builds:

示例包括 Make、Ant、Gulp、Jake、Rake 和 MSBuild 等.

Examples are Make, Ant, Gulp, Jake, Rake and MSBuild to name only a few.

我可以使用根文件夹中的 build.xml 运行 ant 构建.然而,这不是项目的结构.

I am able to run ant builds with the build.xml in the root folder. This is however not how the project is structured.

有没有办法从与工作区根目录不同的目录运行任务命令(在我的例子中是蚂蚁)?

Is there a way to run the task command (ant, in my case) from a directory different to the workspace root?

我想到了类似 git 的 GIT_WORK_TREE 环境变量或执行两个命令的方法(例如 cd {{build.xml folder}} && ant).我目前的 tasks.json 是

I think of something like git's GIT_WORK_TREE environment variable or a way to perform two commands (like cd {{build.xml folder}} && ant). My current tasks.json is

{
    "version": "0.1.0",
    "command": "ant",
    "isShellCommand": true,
    "showOutput": "silent",
    "args": ["all", "jar"],
    "promlemMatcher": "" // I'm also not sure what to put here,
                         // but that's another question
}

(顺便说一句,我在 Windows 上——但来自 linux/osx,我对这里的工作方式有点陌生.)

(I'm on windows, btw -- but come from linux/osx and am kinda new to the ways thinks work here.)

推荐答案

您可以定义要使用的 cwd 目录.这是这样做的:

You can either define the cwd directory to be used. This is done like this:

{
    "version": "0.1.0",
    "command": "ant",
    "isShellCommand": true,
    "options": {
         "cwd": "My folder to run in"
    }
}

参见 https://code.visualstudio.com/Docs/editor/tasks_appendix 用于 tasks.json 文件的定义.

See https://code.visualstudio.com/Docs/editor/tasks_appendix for a definition of the tasks.json file.

这篇关于运行位于任何地方的 ant 构建文件的 VSCode 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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