I wrote some code to get around this this limitation.
I read all entries from class path and determine if it is a folder or a JAR file and then look for the entries in "META_INF/props". If the entry is a property, I load it.
Below is the code, it is not refined but it gives general idea.
try{
URL[] urls = ((URLClassLoader) LoaderTest.class.getClassLoader()).getURLs();
HashMap<String, Properties> mapProperties = new HashMap<String, Properties>();
for(URL url: urls){
File file = new File(url.getFile());
if(file.isDirectory()){
System.out.println("Directory: " +file.getName());
File propFolder = new File(file.getAbsolutePath() + "/META-INF/props");
if (propFolder.exists() && propFolder.isDirectory()){
for(File f: propFolder.listFiles()){
if(f.getName().endsWith("properties") || f.getName().endsWith("props")){
Properties props = new Properties();
props.load(new FileReader(f));
String appName = props.getProperty("load.global.props.appName");
if(appName != null){
if( mapProperties.get(appName) == null) {
mapProperties.put(appName, props);
} else {
mapProperties.get(appName).putAll(props);
}
}
}
}
}
} else if (file.getName().endsWith("jar")){
System.out.println("Jar File: " + file.getName());
JarFile jarFile = null;
try{
jarFile = new JarFile(file);
Enumeration<JarEntry> entries = jarFile.entries();
while ( entries.hasMoreElements() ){
JarEntry entry = entries.nextElement();
if ( entry.getName().startsWith("META-INF/props") &&
(entry.getName().endsWith("properties") ||
entry.getName().endsWith("props"))){
System.out.println("Prop File: " + entry.getName());
Properties props = new Properties();
props.load(jarFile.getInputStream(entry));
String appName = props.getProperty("load.global.props.appName");
if(appName != null){
if( mapProperties.get(appName) == null) {
mapProperties.put(appName, props);
} else {
mapProperties.get(appName).putAll(props);
}
}
}
}
} finally {
if ( jarFile != null ) jarFile.close();
}
}
}
} catch(Exception e){
e.printStackTrace();
}