VSCode Task to run ant buildfile located anywhere

若如初见. 提交于 2019-12-08 09:03:17

问题


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!).

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:

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

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?

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
}

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


回答1:


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"
    }
}

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



来源:https://stackoverflow.com/questions/31958496/vscode-task-to-run-ant-buildfile-located-anywhere

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!