Ant + JavaFront: start Ant tasks from the command line

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.

Explore posts in the same categories: Ant, Blogroll, en

Schlagwörter: , , ,

You can comment below, or link to this permanent URL from your own site.

One Comment - “Ant + JavaFront: start Ant tasks from the command line”

  1. […] Jan’s Blog My personal blog about all and nothing … « Ant + JavaFront: start Ant tasks from the command line […]

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s

%d Bloggern gefällt das: