ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Murdoch" <adammurd...@apache.org>
Subject RE: Problem running ant "by hand". project.configureProject() problem
Date Sun, 27 Oct 2002 21:42:47 GMT

You need to call Project.init() to load up the standard taskdefs (and
typesdefs).  Do this before configuring the project with ProjectHelper.

> -----Original Message-----
> From: Olivier De Wolf [mailto:odwl@skynet.be]
> Sent: Monday, 28 October 2002 1:21 AM
> To: ant-dev@jakarta.apache.org
> Cc: Olivier De Wolf
> Subject: Problem running ant "by hand". project.configureProject()
> problem
>
>
> Hi,
>
>
> I'm making a Servlet that call ant targets. I thinks that'a a good idea
> because I can throw away a lot of compiled code. For perfomance
> reasons, I would like to create A Project object only at init time and
> then execute Target on request.
>
> I did the following :
>
> 		Project project = new Project();
> 		project.setCoreLoader(null);
> 		ProjectHelper.configureProject(project, new
> File("buildServlet.xml"));
> 		System.out.println("Project : "+project.getName());
> 		System.out.println("defaultTarget :
> "+project.getDefaultTarget());
> 		Target target= (Target) project.getTargets().get("usage");
> 		Task task = target.getTasks()[0];
> 		System.out.println("task : "+task.getClass());
> 		//project.executeTarget("usage");
>
> Where buildServlet.xml is :
>
> <project name="compile" default="usage" basedir=".">
> 	<target name="usage">
> 		<echo message="Hello, world"/>
> 	</target>
> </project>
>
>
> I receive the following log :
>
>       [java] Project : compile
>       [java] defaultTarget : usage
>       [java] task : class org.apache.tools.ant.UnknownElement
>
>
> Is It normal that the <echo> task is UnknownElement. I suppose it's not
> because if I uncomment the last line (executeTarget) :
>
> Exception in thread "main" buildServlet.xml:3: Could not create task or
> type of type: echo.
> +the usual advice on classpath.
>
>
> Note : I have all ant lib in my classpath.
>
> I checked the source code of org...ant.Main (that works), but I could
> not find my mistake.
>
>
>
> Thank for your help.
>
>
>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message