Reading the blog Converting maven pom to ivy I asked myself, why it should not be possible to start Ant tasks from the command line.
Stefan on the other side was bored always to here that Ant relies on XML and he presented a way for writing Buildfiles in plain (annotated) Java using JavaFront, a library in Ants sandbox.
Ant provides a way to override the class to start by providing an implementation of AntStart and specifying that class by -main option. So I wrote a new start class which parses the command line parameters and executes that task. The first parameter is the taskname and following parameters are attributes with their values. (There is no support for nested elements yet.)
public class TaskExec implements AntMain {
public void startAnt(String[] args, Properties additionalUserProperties, ClassLoader coreLoader) {
Map attributes = new Hashtable();
// Analyzing the command line arguments
String taskname = args[0];
for(int i=1; iant -lib build\classes -main org.apache.ant.javafront.TaskExec echo message „Hello World“
Other examples are in the launcher script.