agreed
From: seajug-***@public.gmane.org [mailto:seajug-***@public.gmane.org] On Behalf Of
Stuart Maclean
Sent: October-25-13 5:03 PM
To: seajug-***@public.gmane.org
Subject: [seajug] Re: one jar to rule them all
A nice read, but note that someone commented on the tricky part of
packaging content from many jars into one uber-jar. For instance, what
about duplicated resource names??
I have found a nice middle ground. In the 'main' jar, you define in its
Manifest a class-path variable which lists the other, dependent jars.
These then have to be found in the same dir as the initial main jar was
located. I can then add "." to this class-path variable. This allows me
to 'extract' any config files that are located by their loader code
using the classpath. log4j springs to mind, it wants to load its
log4j.properties file from the classpath, which, if you have a monster
uber-jar, means burying that prop file in the jar. Having it on the
filesystem but still loadable via the classpath means you can tell your
'user' to 'edit the log4j.properties file in the directory where all the
jars are, replacing any log level with th word DEBUG'. OK, that's a
stretch but at least it doesn't involve unbundling the uber-jar, editing
the log4.properties file and re-bundling it all back up.
The flip side of the 'many jars + config files' is of course that they
all need packaging up, probably in a ZIP. But with some form of README
likely bundled anyway, this isn't such a big deal.
And of course there is a security hole in placing "." on the classpath,
so it should be listed AFTER all the dependent jars (which, btw Maven's
dependency plugin can derive) else you could have trojan classes being
loaded ahead of intended ones.
So my 2 cents is to actually AVOID the uber-jar solution where possible,
but DO supply all the code required by your application