stringtemplate4
stringtemplate4 copied to clipboard
cached jar files in STGroup.loadGroupFile (Linux only)
I am writing a annotation processing tool with the help of stringtemplate4 which generates java source code from stg template files. Whenever I changed the stg template file (which ends up residing in a jar) and tried to re-generated the source code from that file, I ended up with an old version of that file (unless I waited long enough - then suddenly it worked).
Digging into the stringtemplate source code, I found this (in org.stringtemplate.v4.STGroup.loadGroupFile(String, String)):
URL f = new URL(fileName);
ANTLRInputStream fs = new ANTLRInputStream(f.openStream(), encoding);
From stackoverflow I learned that on linux, the jar file being accessed is cached.
Could you please check if an approach like this
URL f = new URL(fileName);
URLConnection openConnection = f.openConnection();
openConnection.setUseCaches(false);
... = new ANTLRInputStream(openConnection.getInputStream(), encoding);
could be used (maybe in other places as well) to overcome this behaviour?
Thanks a lot for the great library in either case ;)
ouch. thanks