コード例 #1
0
 private String readVersionFromManifest(Class<?> api) throws IOException {
   String className = api.getSimpleName() + ".class";
   URL resource = api.getResource(className);
   log.trace("get resource for {} -> {} -> {}", new Object[] {className, pathOf(api), resource});
   if (resource == null) return null;
   String version = null;
   String classPath = resource.toString();
   if (classPath.startsWith("jar:"))
     version = version(classPath.substring(0, classPath.lastIndexOf("!") + 1));
   if (version == null && classPath.endsWith(pathOf(api) + ".class"))
     version = version(classPath.substring(0, classPath.length() - pathOf(api).length() - 7));
   if (version == null && classPath.contains("/WEB-INF/"))
     version = version(classPath.substring(0, classPath.lastIndexOf("/WEB-INF/")));
   log.debug("version {} for {} from {}.", version, api, classPath);
   return version;
 }