I tried to implement a starter so that you can start a task from the
command line like
        ant -lib JAVAFRONT -main org.apache.ant.javafront.TaskExec echo
message "Hallo Welt"
        ant -lib JAVAFRONT -main org.apache.ant.javafront.TaskExec
echoproperties prefix ant.

In Ant XML:
        <project><echo message="Hallo Welt"/></project>
        <project><echoproperties prefix="ant."/></project>

The starter is:
    public class TaskExec implements AntMain {

        public void startAnt(String[] args, Properties
additionalUserProperties, ClassLoader coreLoader) {
            Map<String, String> attributes = new Hashtable<String,
String>();

            // Analyzing the command line arguments
            String taskname = args[0];
            for(int i=1; i<args.length; ) {
                String attrName  = args[i++];
                String attrValue = args[i++];
                attributes.put(attrName, attrValue);
            }

            // Initializing
            Project    project = initProject();
            TagBuilder builder = TagBuilder.forProject(project);

            // Initializing the Task
            Tag tag = builder.tag(taskname);
            for (String key : attributes.keySet()) {
                tag.withAttribute(key, attributes.get(key));
            }

            // Run the task
            tag.execute();
        }

        private Project initProject() {
            DefaultLogger logger = new DefaultLogger();
            logger.setOutputPrintStream(System.out);
            logger.setErrorPrintStream(System.err);

            Project rv = new Project();
            rv.addBuildListener(logger);
            rv.init();

            return rv;
        }
    }


I cant find the mistake, but there is no output ...
Any ideas?


Jan

Reply via email to