ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Mann <rm...@latencyzero.com>
Subject Re: Loading resources from my task's JAR?
Date Thu, 05 Jan 2006 09:32:46 GMT

On Jan 5, 2006, at 1:04 AM, Steve Loughran wrote:

> 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.

I have verified this. Here's the output of jar tf:

$ jar tf targets/task/dbgen-1.1.jar
META-INF/
META-INF/MANIFEST.MF
com/
com/mycompany/
com/mycompany/tools/
com/mycompany/tools/dbgen/
com/mycompany/tools/dbgen/BaseClass.tmpl          <--
com/mycompany/tools/dbgen/Class.tmpl              <--
com/mycompany/tools/dbgen/Column.class
com/mycompany/tools/dbgen/DBClassGenerator.class
com/mycompany/tools/dbgen/DBClassGeneratorCLI.class
com/mycompany/tools/dbgen/DBGenAntTask.class
com/mycompany/tools/dbgen/PInterface.tmpl         <--
com/mycompany/tools/dbgen/Table.class

The System property java.class.path does not contain my jar or any of  
its classes, but obviously they're getting loaded because the code is  
executing. It may not be significant that my classes aren't in the  
system classpath. However, I'm not sure what the classloader  
arrangement is in this case (I don't know exactly what happens when  
Class.forName() is called).

Now, I'm using the executing class' getResourceAsStream(), so one  
would think it would know where the jar file was.


-- 
Rick



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


Mime
View raw message