Normally, what you put under /src is what you want packaged (in a JAR,
WAR, etc.).
If you put a JAR there, and your sources are packaged as a JAR, you'll
end up with JAR inside your JAR. Which I would say is definitely
technically workable. I'm not sure whether it's a recommended practice
or not.
To load such a JAR file, you'd have to load it as a resource
Thread.getThread().getContextClassLoader().getResource(NAME_OF_THE_JAR_FILE)
, then create a new ClassLoader for that resource -- which will be
binary, so not a URLCLassLoader... Then load the resource/class you need
from that classloader.
Perhaps instead of the above, one could simply create a URLClassLoader
with a "classpath:/NAME_OF_THE_JAR_FILE" URL. I mention it in case, but
IIRC the "classpath:/" resource prefix is something that Spring code
brings, it's not out of the box. Not sure.
Alternatives to all of the above include:
- at or before build time, extracting the files you need from the JAR
and putting them in your /src tree flat;
- putting the JAR file alongside your source tree (in a lib directory)
and making sure it's added to the classpath when the runtime is
launched, in which case you could access classes and resources from it
as though they were in your /src tree.
--
DF.