Posted tagged ‘javafront’

Ant + JavaFront: start Ant tasks from the command line (2)

11. November 2008

In my last blog I wrote about a new AntLib in Ants sandbox: javafront with which you have the ability to start tasks directly from the command line – without any buildfile. With that I was able to do the pom2ivy conversion Torsten Curdt asked for:

task.bat -lib path-to-ivy.jar -xmlns:jar antlib:org.apache.ivy.ant ivy:convertpom pomFile my.pom ivyFile ivy.xml
Advertisements

Ant + JavaFront: start Ant tasks from the command line

7. November 2008

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.