private static boolean isPluginManifest(Manifest mf) { Attributes attr = mf.getMainAttributes(); return attr.getValue("Short-Name") != null && (attr.getValue("Plugin-Version") != null || attr.getValue("Jenkins-Version") != null) || "true".equals(attr.getValue("Jenkins-ClassFilter-Whitelisted")); }
protected String identifyPluginShortName(File t) { try { JarFile j = new JarFile(t); try { String name = j.getManifest().getMainAttributes().getValue("Short-Name"); if (name!=null) return name; } finally { j.close(); } } catch (IOException e) { LOGGER.log(WARNING, "Failed to identify the short name from "+t,e); } return FilenameUtils.getBaseName(t.getName()); // fall back to the base name of what's uploaded }
private static String defaultMainClassName(JarFile jarFile) throws IOException { return jarFile.getManifest().getMainAttributes().getValue("GoCD-Main-Class"); } }
public static String getVersion() { try { ClassLoader classLoader = Jadx.class.getClassLoader(); if (classLoader != null) { Enumeration<URL> resources = classLoader.getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { Manifest manifest = new Manifest(resources.nextElement().openStream()); String ver = manifest.getMainAttributes().getValue("jadx-version"); if (ver != null) { return ver; } } } } catch (Exception e) { LOG.error("Can't get manifest file", e); } return "dev"; } }
private static void parseClassPath(Manifest manifest, File archive, List<File> paths, String attributeName, String separator) throws IOException { String classPath = manifest.getMainAttributes().getValue(attributeName); if(classPath==null) return; // attribute not found for (String s : classPath.split(separator)) { File file = resolve(archive, s); if(file.getName().contains("*")) { // handle wildcard FileSet fs = new FileSet(); File dir = file.getParentFile(); fs.setDir(dir); fs.setIncludes(file.getName()); for( String included : fs.getDirectoryScanner(new Project()).getIncludedFiles() ) { paths.add(new File(dir,included)); } } else { if(!file.exists()) throw new IOException("No such file: "+file); paths.add(file); } } }
/** * Won't be available on Android or on any builds not using our build.xml. * * @return 0 if unknown */ private static long getBuildTime(SimpleDateFormat fmt, String jar) { if (SystemVersion.isAndroid()) return 0; File f = new File(I2PAppContext.getGlobalContext().getBaseDir(), "lib"); f = new File(f, jar); Attributes atts = attributes(f); if (atts == null) return 0; String s = atts.getValue("Build-Date"); if (s == null) return 0; try { Date date = fmt.parse(s); if (date != null) { return date.getTime(); } } catch (ParseException pe) {} return 0; }
private static String kotlinVersionByJar() { StringBuilder kotlinVersion = new StringBuilder(""); JarInputStream kotlinJar = null; try { Class<?> kotlinUnit = Class.forName("kotlin.Unit"); kotlinVersion.append("kotlin"); kotlinJar = new JarInputStream(kotlinUnit.getProtectionDomain().getCodeSource().getLocation().openStream()); String version = kotlinJar.getManifest().getMainAttributes().getValue("Implementation-Version"); concat(kotlinVersion, version, "/"); } catch (ClassNotFoundException e) { //Ignore } catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception attempting to get Kotlin version.", e); } } finally { closeQuietly(kotlinJar, log); } return kotlinVersion.toString(); }
public static void print() throws IOException { InputStream manifestStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("META-INF/MANIFEST.MF"); try { Manifest manifest = new Manifest(manifestStream); Attributes attributes = manifest.getMainAttributes(); String impVersion = attributes.getValue("Implementation-Version"); System.out.println(attributes); } catch (IOException ex) { ex.printStackTrace(); } }
public static void logVersion() { try { Enumeration<URL> resources = Version.class.getClassLoader().getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { Manifest manifest = new Manifest(resources.nextElement().openStream()); Attributes attrs = manifest.getMainAttributes(); if (attrs == null) { continue; } String name = attrs.getValue("Bundle-Name"); if (name != null && name.equals("Redisson")) { log.info("Redisson " + attrs.getValue("Bundle-Version")); break; } } } catch (Exception E) { // skip it } }
public static String getCruiseVersion(String jar) { String version = null; try { JarFile jarFile = new JarFile(jar); Manifest manifest = jarFile.getManifest(); if (manifest != null) { Attributes attributes = manifest.getMainAttributes(); version = attributes.getValue("Go-Version"); } } catch (IOException e) { } return version; }
Attributes attributes = manifest.getMainAttributes(); if (attributes == null) { return; String s = attributes.getValue(Attributes.Name.CLASS_PATH); if (s == null) { return; file = new File(base, t); file = file.getCanonicalFile(); if (!file.exists()) { file = new File(t); file = file.getCanonicalFile(); if (!file.exists()) { URL url = new URL(t); file = new File(url.getFile()); file = file.getCanonicalFile(); if (!file.exists()) {
private static String kotlinVersionByJar() { StringBuilder kotlinVersion = new StringBuilder(""); JarInputStream kotlinJar = null; try { Class<?> kotlinUnit = Class.forName("kotlin.Unit"); kotlinVersion.append("kotlin"); kotlinJar = new JarInputStream(kotlinUnit.getProtectionDomain().getCodeSource().getLocation().openStream()); String version = kotlinJar.getManifest().getMainAttributes().getValue("Implementation-Version"); concat(kotlinVersion, version, "/"); } catch (ClassNotFoundException e) { //Ignore } catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception attempting to get Kotlin version.", e); } } finally { closeQuietly(kotlinJar, log); } return kotlinVersion.toString(); }
public static void print() throws IOException { InputStream manifestStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("META-INF/MANIFEST.MF"); try { Manifest manifest = new Manifest(manifestStream); Attributes attributes = manifest.getMainAttributes(); String impVersion = attributes.getValue("Implementation-Version"); System.out.println(attributes); } catch (IOException ex) { ex.printStackTrace(); } }
private String getVersionOf(Manifest manifest) { String v = manifest.getMainAttributes().getValue("Plugin-Version"); if(v!=null) return v; // plugins generated before maven-hpi-plugin 1.3 should still have this attribute v = manifest.getMainAttributes().getValue("Implementation-Version"); if(v!=null) return v; return "???"; }
private static String getManifestKey(JarFile jarFile, String key) { try { Manifest manifest = jarFile.getManifest(); if (manifest != null) { Attributes attributes = manifest.getMainAttributes(); return attributes.getValue(key); } } catch (IOException e) { LOG.error("Exception while trying to read key {} from manifest of {}", key, jarFile.getName(), e); } return null; }
public static void logVersion() { try { Enumeration<URL> resources = Version.class.getClassLoader().getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { Manifest manifest = new Manifest(resources.nextElement().openStream()); Attributes attrs = manifest.getMainAttributes(); if (attrs == null) { continue; } String name = attrs.getValue("Bundle-Name"); if (name != null && name.equals("Redisson")) { log.info("Redisson " + attrs.getValue("Bundle-Version")); break; } } } catch (Exception E) { // skip it } }
/** * Returns String with version of backup .war file, * if the file does not exists returns null */ public String getBackupVersion() { try { try (JarFile backupWar = new JarFile(new File(Lifecycle.get().getHudsonWar() + ".bak"))) { Attributes attrs = backupWar.getManifest().getMainAttributes(); String v = attrs.getValue("Jenkins-Version"); if (v == null) v = attrs.getValue("Hudson-Version"); return v; } } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to read backup version ", e); return null;} }
Attributes attributes = manifest.getMainAttributes(); if (attributes == null) { return; String s = attributes.getValue(Attributes.Name.CLASS_PATH); if (s == null) { return; file = new File(base, t); file = file.getCanonicalFile(); if (!file.exists()) { file = new File(t); file = file.getCanonicalFile(); if (!file.exists()) { URL url = new URL(t); file = new File(url.getFile()); file = file.getCanonicalFile(); if (!file.exists()) {
@DesireNoWarning("NP_LOAD_OF_KNOWN_NULL_VALUE") public String falsePositive (ServletContext servletContext) throws IOException { try (InputStream inputStream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF")) { if (inputStream == null) { return "#InDevelopment#"; } return new Manifest(inputStream).getMainAttributes().getValue("Implementation-Version"); } } }
static String computeShortName(Manifest manifest, String fileName) { // use the name captured in the manifest, as often plugins // depend on the specific short name in its URLs. String n = manifest.getMainAttributes().getValue("Short-Name"); if(n!=null) return n; // maven seems to put this automatically, so good fallback to check. n = manifest.getMainAttributes().getValue("Extension-Name"); if(n!=null) return n; // otherwise infer from the file name, since older plugins don't have // this entry. return getBaseName(fileName); }