ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <ddevie...@gmail.com>
Subject Re: Importing and caching build files from a URL
Date Tue, 29 Nov 2005 17:57:46 GMT
> Now how do I get the parent? You can parse the path manually, but a URL can
> be a jar resource, HTTP address, file location, newsgroup, partial url, etc.
>
> http://archive.ncsa.uiuc.edu/SDG/Software/Mosaic/Demo/url-primer.html
>
> Rather than parsing the path, it's easier and more explicit to simply
> declare the root.
> Also, this is more powerful since you can do relative imports from the root.
> Solving two problems at once. Now the build writer decides how build files
> are resolved. They can be relative to the orginal build file as described
> above or relative to another root.

As you can see from the code below and how it works, there is no
parsing required. The URL class does it all, and behaves as the URL
RFC dictactes. This is how HTML documents resolve each other. There's
no reason to have any explicit root, although just like in HTML, one
could change the default context for a document using a base-like HTML
attribute.

The fact that you cannot "browse" a URL doesn't mean you can't know
the parent (context) of a given URL, as the code clearly demonstrates
IMHO. --DD

D:\org_apache>java MakeUrl file:/C:/ant/ build.properties
file:/C:/ant/build.properties

D:\org_apache>java MakeUrl file:/C:/ant build.properties
file:/C:/build.properties

D:\org_apache>java MakeUrl file:/C:/ant/build.xml build.properties
file:/C:/ant/build.properties

D:\org_apache>java MakeUrl file:/C:/ant/ build.properties
file:/C:/ant/build.properties

D:\org_apache>java MakeUrl file:/C:/ant build.properties
file:/C:/build.properties

D:\org_apache>java MakeUrl http://foo/common.xml misc.xml
http://foo/misc.xml

D:\org_apache>type MakeUrl.java
import java.net.URL;
public class MakeUrl {
  public static void main(String[] args) throws Exception {
    URL parent = new URL(args[0]);
    System.out.println(new URL(parent, args[1]).toString());
  }
}

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


Mime
View raw message