ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <>
Subject Re: Loading resource or property files embedded in jar file that distributes shared build files?
Date Fri, 08 Apr 2011 14:59:07 GMT
On Fri, Apr 8, 2011 at 9:09 AM, Steele, Richard <> wrote:
> I've created a reusable set of build files using the technique I outlined at
> This technique relies heavily on Ant 1.8 importing files from the classpath
> rather than from a file.
> An issue I've run into, however, is how would my reusable build files (the
> ones embedded in the jar file) load a properties file or resource from that
> shared jar file?  It doesn't appear that by default either <properties
> resource=""> or <loadresource> has access to resources that are in the
> originating jar file.  I'd specify the classpath but--what would that be?
> I've tinkered with writing a script or custom task to help me figure out how
> to get the classpath (or classloader, for that matter) that corresponds to
> the source jar file, but without any luck.

  My approach to this is a little different than yours as I
import/include resources rather than using Antlibs for my
compartmentalized build, in a manner similar to Joe Scmetzer's [1].
This allows me to make use of the ant.file.projectname and
ant.file.type.projectname properties, which I query, ultimately, in a
macrodef that uses the file vs. url information exposed therein to
understand how to obtain a relative resource.  For good measure I also
provide macrodefs to include-relative and import-relative which
themselves delegate back to the all-important macro that actually
determines what a relative resource looks like.  It might be possible
for similar properties to be added to Ant for Antlibs, but from what I
can tell so far it would indeed be a good bit trickier than the
approach I describe.


> Thanks,
> Rich

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

View raw message