5

What would you choose as the default Ant target?
In the context of a small visual tool with a user interface, open source.

I was thinking about jar because the project's distributable is the jar file.

But someone prefers to have help as the default target, to show the available targets.

Or maybe another target? I doubt anyone would really care, but would be the "least surprise" choice?

1
  • I think "least surprise" target would be maven :)
    – gnat
    Jul 6, 2012 at 7:37

2 Answers 2

3

The name of the default Ant target is not as important as setting it to whichever target will be used most frequently by end users. Good default target names include:

  • build
  • dist
  • jar
  • main

If your Ant project contains many targets, it can be confusing to new users to read through all the target descriptions (e.g. by listing all the targets by default). The first time building a new project it is convenient to be able to type ant at the command prompt and get the desired deliverable.

Each target should be documented by utilizing the description attribute so that running ant -p provides sufficient information for most users to quickly evaluate the remaining targets in your project. The same principles apply when running the Ant build from within a GUI.

1

This is just personal preference - as any answer to this question is likely to be:

I tend to always have help as the default target. My reasoning is that unless you've looked at the build script or have used it before, you don't know what exactly you're going to get if you just calling the default target.

Even if your projects all use the same set of standard targets, there might be custom properties which will affect what you get out - e.g. build for debug/release, or create a signed/unsigned jar. I tend to have the default help target just display that non-standard info, alongside a couple of example usages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.