Sublime Forum

Run external tools (ant)

#1

how can I run an external ant build from the root of a project directory?

0 Likes

#2

I’ll include an ant build system in the next version, but in the mean time you can create one yourself. Save this:

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

as Packages/Java/Ant.sublime-build, and restart. The location of the Packages directory varies based on operating system; you can navigate to it via Preferences/Browse Packages.

0 Likes

#3

awesome thanks.

I’ve tried to adapt the specified code for Android, but Sublime is smarter than I am apparently.

For the simplest cases, when you build an Android app via ant, you can target “compile”, “debug”, “install”, and “release”. For instance:

ant compile

will build any missing classes (such as R.java) and compile your code

ant debug

as above, and will build an unsigned version of your app

ant install
same as “ant debug”, but will also install the app on a default emulator or physical device

ant release
create a signed version of your app, assuming you have a keystore specified in your build.properties (which exists in your project root)

So I tried this:

{ "cmd": "ant compile"], "working_dir": "${project_path:${folder}}" }

but I get an error message

[Errno 2] No such file or directory [Finished]

How can I fix this? Also, should I be creating a new “build system” for each of the ant targets (compile, debug,install,release)?

tia!

0 Likes

#4

The command needs to be entered as “ant”, “compile”] - there’s some documentation on build systems at sublimetext.info/docs/core/build_systems.html

0 Likes

#5

You could, alternatively, insert a new task in your build file that does all 4 actions.

<target name="all" depends="compile, debug, install, release" description="Build android application." />

Just drop that in anywhere in the root element ().

0 Likes