ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: Loading resources from my task's JAR?
Date Thu, 05 Jan 2006 09:04:27 GMT
Rick Mann wrote:
> I wrote an Ant task that needs to load some files (it's a source  
> generator that loads template files). I'd like to store those files  in 
> the task's .jar file, but so far I've met with no success. I've  tried 
> storing the files in various parts of the .jar:
> 
> templates/Class.tmpl
> com/mycompany/tools/dbgen/Class.tmpl
> Class.tmpl
> 
> and I've tried getting at it with (and more) from within my task's code:
> 
> getClass().getResourceAsStream("templates/Class.tmpl")

this should work. make sure you have put the template into the JAR. the 
<jar> task may need to explicitly ask for it, or you should be using 
<copy> to copy the files from their source dir to build/classes or wherever.

I would have an "unjar" target that used <unjar> to unjar a jar just 
built, so you can see what is going on. Once you are 100% sure that the 
resource is going in, then you can worry about classloading.

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


Mime
View raw message