ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yves Martin <>
Subject Re: Patch proposal for 1.6.3: parse a Ant project from a resource
Date Thu, 27 Jan 2005 12:54:29 GMT
Peter Reilly <> writes:

> The problem is that this will not set the basedir correctly.
> (The basedir will be set to something like:
> File(url_string).getParentFile().getAbsolutePath()).
> This will cause all sorts of problems and is the reason why
> <import url="..."/> has not been implemented.

 OK. It is a good reason.

 My build system loads Ant project files from the disk, and I just adapt the
 code to load them from a JAR resources.

 I can say to you that such a code (set basedir, listener and project name) is
 working with both a File and a URL in my build system context as fas as the
 exception is not thrown in the ProjectHelper2:

  public static Project loadAntProject(Project currentProject,
                                       Object antproject) {
      ProjectHelper helper =
          (ProjectHelper) currentProject.getReference("ant.projectHelper");

      Project project = new Project();

      // Copy listeners to enable logging
      Iterator listenerIt = currentProject.getBuildListeners().iterator();
      while (listenerIt.hasNext()) {
          BuildListener bl = (BuildListener);
          currentProject.log("  Adding listener " + bl, Project.MSG_DEBUG);

      project.addReference("ant.projectHelper", helper);

      helper.parse(project, antproject);

      // Set project name
      AntXMLContext context = null;
      context = (AntXMLContext)
      return project;

 Isn't it possible to remove the exception 'throw' statement and document the
 method to say that parsing a URL is at your own risk (I aggree to take it ;)) ?

 In fact, ProjectHelper2 is not opened enough (private attributes) to be
 inherited to change such a small part of code...

 Please help me, comment that part of code that never occurs finally (as far as
 import url is not implemented as your said) !
 Many thanks in advance
Yves Martin

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message