I wanted to do the same thing. The anthill stuff looked too complex for what I wanted but I couldn't find anything else that does this. I looked at invoking the main() startup method inside ant but that makes System.exit() calls.

I got a very basic servlet working, though, by cloning a very stripped down version of the ant source code that runs when you invoke ant on the cmd line. The code below works for me under tomcat 4.1.18 but doesn't support build listeners, loggers, default targets or input handlers. Most of this was copied from org.apache.tools.ant.Main.runBuild.

import org.apache.tools.ant.*;
import org.apache.tools.ant.input.*;


Project project = new Project();
project.setCoreLoader(getClass().getClassLoader());

project.setInputHandler(new DefaultInputHandler());
project.init();
project.setUserProperty("ant.version", Main.getAntVersion());
File buildFile = new File("build.xml");
project.setUserProperty("ant.file",
buildFile.getAbsolutePath());

ProjectHelper.configureProject(project, buildFile);

Vector target = new Vector();
target.add(new String("mytarget"));
project.executeTargets(target);




[EMAIL PROTECTED] wrote:
Have you looked at anthill?

http://www.urbancode.com/projects/anthill/default.jsp


-----Original Message-----
From: Roman Rytov [mailto:[EMAIL PROTECTED]]
Sent: 20 January 2003 07:23
To: Ant Users List
Subject: Runing Ant from JSP (servlet)


I need a way to run ant buildfiles from web interface. Is there any
custom tag already written or any other way?
RR

--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>







--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to