I´m using Sublime Text 2 together with the ant build system. CTRL+B works perfectly fine to start the build with the default target. However my question is, is there a ways to define different ant build targets and have a mechanism to switch between them easily?
I thought about creating additional custom build commands for each target - for example like "clean". It works, but that is not the best approach in my eyes because you have to go to "Tools > Build System > Ant (clean)" and hit CTRL+B afterwards.
Save this build file as *.sublime-build file in the Packages/User folder
{
"selector": "source.java",
"cmd": ["ant"],
"variants": [
{ "cmd": ["solve_world_hunger"],
"name": "Solve World Hunger"
},
{ "cmd": ["ant", "clean"],
"name": "Run"
}
]
}
ctrl+b
Run
in the variants
array will run on ctrl+shift+b
name
. i.e. hit ctrl+shift+p
and type Solve World Hunger
to run the solve world hunger command.You can declare variants as shown in the other solutions. I also like to add in this to my user keybindings:
{
"keys": ["ctrl+b"],
"command": "show_overlay",
"args": {"overlay": "command_palette", "text": "Build:"}
},
With this, you can hit ctrl+b then after that, either enter for the default build, or start typing the variant type. c for clean r for release, whatever.
This is what I had to do to get mine to work on windows 7, like the answer above save it in your Packages/User folder and then you can trigger different build targets by pressing ctrl+shift+p and typing the name of the command within the variants section of the script below.
Hope this helps some people :)
{
"working_dir": "${project_path:${folder}}",
"selector": "source.java",
// DEFAULT COMMAND TO EXECUTE FOR A BUILD SCRIPT ** OPTIONAL **
//"cmd": ["ant.bat", "deploy_test"],
"variants":
[
{ "cmd": ["ant.bat", "deploy_test"],
"name": "Laravel Deploy Dev"
},
{ "cmd": ["ant.bat", "deploy_delete"],
"name": "Laravel Delete"
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With