Sublime Text 2 Ant Build Target: [Error 2] The sys

2019-08-31 04:32发布

问题:

When I run the basic Ant Build from Sublime Text 2 (Ctrl+B), it works, but it runs all targets. I want to specify/override the default build target. I added a new build system like:

{
    "cmd": ["ant", "my_target"]
}

But it fails with:

[Error 2] The system cannot find the file specified
[Finished]

Whats wrong?

回答1:

The sublimetext buildsystems documentation page show how you can make a special case to execute "ant.bat" instead of "ant" on Windows. See the section "Platform-specific Options":

The windows, osx and linux elements let you provide platform-specific data in the build system. Here’s an example:

{
    "cmd": ["ant"],
    "file_regex": "^ *\\[javac\\] (.+):([0-9]+):() (.*)$",
    "working_dir": "${project_path:${folder}}",
    "selector": "source.java",

    "windows":
    {
        "cmd": ["ant.bat"]
    } 
}

In this case, ant will be executed for every platform except Windows, where ant.bat will be used instead.

Does that help?