Some people start internal targets with dashes just to make sure users cannot run them from the command line. In fact, I make it a standard practice to have all internal targets start with -
just for this reason.
You can try the old double-dash trick. I don't have Ant installed on my current system, so I can't test it. Double dashes is a common Unix trick that most commands use to help end parameters when you have files and stuff that start with a dash. By the way, the tasks should be the last thing on your command line:
$ ant -f test.xml -- -task1
Worse comes to worse, you can simply define another target in your build.xml
file that depends upon this target with the dash in it:
<task name="sneaky"
depends="-task1"/>
Then you should be able to call sneaky
:
$ant -f test.xml sneaky