ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: Possible TaskDef donation
Date Thu, 13 Mar 2003 15:02:04 GMT
This is indeed interesting. I do something quite similar for another purpose
(scans a JAR for all classes having a give static method signature, executes
all these methods, gathering the meta-info required, generate a XML file
then stuck into the JAR's META-INF directory).

Something I do is to restrict scanning classes to only those that match a
given patternset to speed things up (you often know which part of your
package tree to look things, or could use a naming convention to find things
faster). This makes the scanning quite a bit faster (we have big JARs).

All this to say that you specific use case if very useful, but the more
generic action all scanning the classes of a JAR and doing something that
ultimately updated the JAR somehow would be even more useful. Allowing to
plug over 'actions' rather than the default 'looking for services' would be
very very useful IMHO.

What are your dependencies? BCEL? Do you load the actual classes (so need
dependent classes on the classpath)?

Thanks for sharing this with us. --DD

PS: BTW, I don't think you can edit the JAR in place...

-----Original Message-----
From: Berin Loritsch [] 
Sent: Wednesday, March 12, 2003 4:13 PM
Subject: Possible TaskDef donation

Currently, if you want to support the JAR Services standard set forth
by Sun, you have to create a file with an interface name in
META-INF/services and list all the implementations.

This can get to become a problem if we are adding and removing classes,
and we forget to update this hand maintained file.

I wrote an ANT task that will scan an existing JAR, and find all the
classes that implement the specified interfaces.  The task verifies
that the supplied service name *is* in fact an interface, and then
it checks every class in the JAR to see if it implements that interface.

After it collects all this information it adds a new entry for each
interface, with the list of implementations for each service.

For now it needs to use an input jar and an output jar because I could
not figure out how to modify the jar in place.

As more project adopt this standard, it would be nice to include in
ANT proper.

If you are interested, I can post the source code.

View raw message